-
-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Description
When the dropdown is opened by clicking the toggle arrow button with data-action="toggle", clicking outside the dropdown does not close it. This happens because the input element does not receive focus when the dropdown is opened in this way, and the component relies on the blur event from the input to close the dropdown.
Steps to reproduce
- Click the toggle arrow button to open the dropdown.
- Click anywhere outside the dropdown.
- Observe that the dropdown does not close.
Expected behavior
Clicking outside the dropdown should close it, regardless of how the dropdown was opened.
Proposed Solution
To fix this issue, omit data-action="toggle" from the toggle arrow button. Without data-action="toggle", the click will trigger focusControl, which ensures the input is focused. This allows the blur event to fire when clicking outside, correctly closing the dropdown.
Additional Context
The issue occurs because data-action="toggle" bypasses the logic in focusControl that focuses the input. This prevents the dropdown from responding to outside clicks via the on_blur handler.