MCPcopy
hub / github.com/Choices-js/Choices / showDropdown

Method showDropdown

src/scripts/choices.ts:504–536  ·  view source on GitHub ↗
(preventInputFocus?: boolean)

Source from the content-addressed store, hash-verified

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

Callers 15

_displayNoticeMethod · 0.95
_onKeyDownMethod · 0.95
_onEnterKeyMethod · 0.95
_onDirectionKeyMethod · 0.95
_onTouchEndMethod · 0.95
_onClickMethod · 0.95
_onFocusMethod · 0.95
choices.jsFile · 0.80
choices.mjsFile · 0.80

Calls 6

getClassNamesSelectorFunction · 0.90
isScrolledIntoViewFunction · 0.90
showMethod · 0.80
openMethod · 0.80
focusMethod · 0.80
triggerEventMethod · 0.80

Tested by

no test coverage detected