Auto-focus Search Input in Visualization Type Modal #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the user experience in the "Change Visualization Type" modal by automatically focusing the search input when the modal opens, eliminating the need for users to manually click on the search field before typing.
Problem
Currently, when users open the "Change Visualization Type" modal, they must manually click on the search input field before they can start typing to search for visualization types. This adds an unnecessary step to the workflow and creates friction in the user experience.
Before:
Screen.Recording.2025-10-12.at.18.54.02.mov
After:
Screen.Recording.2025-10-12.at.19.40.39.mov
Solution
useRefhook to create a reference to the search input elementuseEffecthook to automatically focus the search input when theVizTypeGallerycomponent mountssetTimeoutwith 150ms delay to ensure the modal animation completes before focusingChanges Made
Files Modified
superset-frontend/src/explore/components/controls/VizTypeControl/VizTypeGallery.tsxuseRefanduseEffectimportssearchInputRefto reference the search inputsuperset-frontend/src/explore/components/controls/VizTypeControl/VizTypeControl.test.tsxjest.useFakeTimers()andjest.runAllTimers()for reliable testingscroll-into-view-if-neededto prevent test failureswaitForTechnical Details
Implementation
Testing
setTimeoutbehaviorBenefits
Use Cases
Testing
Accessibility
Backward Compatibility
Related Issues
Type: Enhancement
Impact: User Experience
Breaking Changes: None
Dependencies: None