-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(insights): Do not close UnitPicker modal when clicking inside it #31024
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
This PR refactors the custom unit modal in UnitPicker to address unexpected dropdown closures by moving the modal to a global level.
- Introduced
/frontend/src/lib/components/UnitPicker/GlobalCustomUnitModal.tsx
to handle modal rendering globally. - Updated
/frontend/src/lib/components/UnitPicker/UnitPicker.tsx
to trigger modal actions via the new global logic. - Added
/frontend/src/lib/components/UnitPicker/unitPickerModalLogic.ts
for centralized modal state management. - Removed the obsolete
/frontend/src/lib/components/UnitPicker/CustomUnitModal.tsx
component. - Integrated the global modal in
/frontend/src/layout/GlobalModals.tsx
.
5 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile
Size Change: -282 B (0%) Total Size: 13.2 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏
📸 UI snapshots have been updated2 snapshot changes in total. 0 added, 2 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
Problem
The UnitPicker component has a modal interaction issue where clicking inside the Custom prefix/postfix modal causes the parent dropdown to close unexpectedly. This happens because the modal is rendered in a Portal (outside the DOM hierarchy), but the dropdown's click detection still registers clicks inside the modal as "outside clicks" that should close the dropdown.
The issue creates a frustrating user experience as users are unable to effectively configure custom units for their visualizations.
Closes #31011
Changes
The solution completely redesigns the modal architecture to use global state management instead of relying on DOM event propagation:
This approach is more robust because it completely avoids the event bubbling conflicts by separating the modal from the dropdown DOM hierarchy.
Does this work well for both Cloud and self-hosted?
Yes
How did you test this code?
Tested locally and it works, should not change code that affects any other components but this custom modal.