coreui-react icon indicating copy to clipboard operation
coreui-react copied to clipboard

CDropdown closes when clicking scrollbar from CDropdownMenu overflow

Open jasperfirecai2 opened this issue 10 months ago • 4 comments

Report

When using autoClose={true} (default) or autoClose='inside', clicking on a scrollbar also autocloses the dropdown, making scrolling inaccessible except via scroll-wheel or keyboard. This is a regression compared to coreui v3 Example code:

<CDropdown direction="center">
  <CDropdownToggle
    caret={false}
  >
    <div>open dropdown</div>
  </CDropdownToggle>
  <CDropdownMenu style={{maxHeight: '25vh', overflowY: "auto"}}>
    {[...Array(10).keys()].map(item => (
      <CDropdownItem key={item} href="#" role="menuitem">
        {item}
      </CDropdownItem>
    ))}
  </CDropdownMenu>
</CDropdown>

Details

  • Operating system and version: Windows 11
  • Browser and version: Firefox stable

jasperfirecai2 avatar Feb 24 '25 13:02 jasperfirecai2

@jasperfirecai2 I will fix it in the next release.

mrholek avatar Feb 24 '25 13:02 mrholek

Many thanks for the quick reply. I also seem to be getting a warning about a browser issue regarding scroll events when i switched to state-controlled visibility.. This sometimes makes the dropdown bug out and float at 0,0 of the document. not 100% sure this code alone can reproduce it. example code below.

want me to make another issue for that?

const ExampleComponent = () => {
  const [dropdownVisible, setDropDownVisible] = useState(false);

  const handleSelect = (_event) => {
    setDropDownVisible(false);
  };

  return (
    <CDropdown
      direction="center"
      visible={dropdownVisible}
      onHide={() => setDropDownVisible(false)}
      onShow={() => setDropDownVisible(true)}
      autoClose="outside"
    >
      <CDropdownToggle
        caret={false}
        onClick={() => setDropDownVisible(!dropdownVisible)}
      >
        <div>toggle dropdown</div>
      </CDropdownToggle>
      <CDropdownMenu style={{maxHeight: '25vh', overflowY: "auto"}}>
        {[...Array(10).keys()].map(item => (
          <CDropdownItem
            key={item}
            onClick={handleSelect}
            href="#"
            role="menuitem"
          >
            {item}
          </CDropdownItem>
        ))}
      </CDropdownMenu>
    </CDropdown>
  );
};

edit: this is an issue with popper and can be fixed with popper={false}. not relevant to this issue

jasperfirecai2 avatar Feb 24 '25 14:02 jasperfirecai2

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar May 06 '25 14:05 github-actions[bot]

@mrholek did you manage to find a fix for the autoClose?

jasperfirecai2 avatar May 12 '25 16:05 jasperfirecai2

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Jul 13 '25 14:07 github-actions[bot]

Not stale, still an issue until closed by holek

jasperfirecai2 avatar Jul 13 '25 14:07 jasperfirecai2

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions

github-actions[bot] avatar Sep 13 '25 14:09 github-actions[bot]

@jasperfirecai2 working on it

mrholek avatar Sep 14 '25 11:09 mrholek