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.
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 theblurevent from the input to close the dropdown.Steps to reproduce
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. Withoutdata-action="toggle", the click will triggerfocusControl, which ensures the input is focused. This allows theblurevent to fire when clicking outside, correctly closing the dropdown.Additional Context
The issue occurs because
data-action="toggle"bypasses the logic infocusControlthat focuses the input. This prevents the dropdown from responding to outside clicks via theon_blurhandler.