You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Thank you for the quick response and for clarifying that this behavior is intentional.
However, this approach introduces a usability issue:
When the dropdown is opened without focusing the input (via data-action="toggle"), clicking outside does not close the dropdown. This can confuse users and lead to unexpected behavior, as the dropdown remains open until the toggle button is clicked again.
Would it be possible to implement an alternative solution that accommodates both scenarios? For example:
Allow the dropdown to close on outside clicks even when opened via data-action="toggle". This could be achieved with a "click-outside" listener or by ensuring the dropdown closes on any interaction outside the component.
Provide a clear configuration option to choose whether data-action="toggle" should also focus the input or not, so developers can tailor it to their use case (e.g., desktop vs. mobile).
This would maintain the flexibility of toggling without focus while addressing the dropdown closure issue for users who expect outside clicks to always close it.
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 theblur
event 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 theblur
event to fire when clicking outside, correctly closing the dropdown.Additional Context
The issue occurs because
data-action="toggle"
bypasses the logic infocusControl
that focuses the input. This prevents the dropdown from responding to outside clicks via theon_blur
handler.The text was updated successfully, but these errors were encountered: