| 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) => { |