MCPcopy Create free account
hub / github.com/decaporg/decap-cms / focus

Function focus

packages/decap-cms-widget-list/src/ListControl.js:604–630  ·  view source on GitHub ↗
(path)

Source from the content-addressed store, hash-verified

602 };
603
604 focus(path) {
605 const [index, ...remainingPath] = path.split('.');
606
607 if (this.state.listCollapsed || this.state.itemsCollapsed[index]) {
608 const newItemsCollapsed = [...this.state.itemsCollapsed];
609 newItemsCollapsed[index] = false;
610 this.setState(
611 {
612 listCollapsed: false,
613 itemsCollapsed: newItemsCollapsed,
614 },
615 () => {
616 const key = this.state.keys[index];
617 const control = this.childRefs[key];
618 if (control?.focus) {
619 control.focus(remainingPath.join('.'));
620 }
621 },
622 );
623 } else {
624 const key = this.state.keys[index];
625 const control = this.childRefs[key];
626 if (control?.focus) {
627 control.focus(remainingPath.join('.'));
628 }
629 }
630 }
631
632 // eslint-disable-next-line react/display-name
633 renderItem = (item, index) => {

Callers 1

ObjectControl.jsFile · 0.50

Calls 1

focusMethod · 0.45

Tested by

no test coverage detected