Skip to content

Using portal prop closes dropdown when clicking interactable areas in the dropdown #308

@shirleyxiao1103

Description

@shirleyxiao1103

Hello,
I'm utilizing the props portal to show the dropdown in the document.body like the example you have in your examples. However when I add the portal, anywhere I click inside the dropdown closes the dropdown and calls onDropdownClose. e.g if I try to click into the input field or if I try to click on an option while in multi select. At the moment the only way I can keep it open is if I utilize the keepOpen prop. Have any ideas on what could be closing the dropdown right away?

These are the other props I am currently using as well

<Select
        className={classNames.join(' ')}
        // dropdownPosition={dropdownPosition}
        // keepOpen={keepDropdownOpen}
        options={data}
        values={selectedOptions}
        disabled={isDisabled}
        dropdownGap={0}
        closeOnSelect={false}
        multi={isMulti}
        backspaceDelete={false}
        dropdownRenderer={customDropdownRenderer}
        contentRenderer={customContentRenderer}
        dropdownHandleRenderer={({ state }) => customDropdownHandleRenderer({ state, isMobile })}
       // onDropdownOpen={(e) => {
        //   onDropdownOpen(e);
        //   calculateDropdownSize();
        //   setKeepDropdownOpen(true);
        // }}
        onDropdownClose={(event) => {
          handleDropdownClose(event);
          console.log('onDropdownClose: ', event);
        }}
        handleKeyDownFn={handleKeyDownFn}
        portal={typeof document !== `undefined` && document.body}
        additionalProps={additionalProps}
      />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions