(preventInputFocus?: boolean)
| 502 | } |
| 503 | |
| 504 | showDropdown(preventInputFocus?: boolean): this { |
| 505 | if (this.dropdown.isActive) { |
| 506 | return this; |
| 507 | } |
| 508 | |
| 509 | if (preventInputFocus === undefined) { |
| 510 | // eslint-disable-next-line no-param-reassign |
| 511 | preventInputFocus = !this._canSearch; |
| 512 | } |
| 513 | |
| 514 | requestAnimationFrame(() => { |
| 515 | this.dropdown.show(); |
| 516 | const rect = this.dropdown.element.getBoundingClientRect(); |
| 517 | this.containerOuter.open(rect.bottom, rect.height); |
| 518 | |
| 519 | if (!preventInputFocus) { |
| 520 | this.input.focus(); |
| 521 | } |
| 522 | |
| 523 | this.passedElement.triggerEvent(EventType.showDropdown); |
| 524 | |
| 525 | const activeElement = this.choiceList.element.querySelector<HTMLElement>( |
| 526 | getClassNamesSelector(this.config.classNames.selectedState), |
| 527 | ); |
| 528 | |
| 529 | if (activeElement !== null && !isScrolledIntoView(activeElement, this.choiceList.element)) { |
| 530 | // scrollIntoView can cause entire page scrolling, scrollToChildElement causes undesired animation |
| 531 | this.choiceList.element.scrollTop = activeElement.offsetTop; |
| 532 | } |
| 533 | }); |
| 534 | |
| 535 | return this; |
| 536 | } |
| 537 | |
| 538 | hideDropdown(preventInputBlur?: boolean): this { |
| 539 | if (!this.dropdown.isActive) { |
no test coverage detected