Skip to content

Conversation

@coseeian
Copy link
Collaborator

@coseeian coseeian commented Jan 26, 2026

Summary

Fixes #914 - Restores focus management after search submission to improve keyboard navigation and screen reader accessibility.

Problem: When users clicked the "Submit search" button, focus was lost as the button disappeared from the DOM and was replaced with the "Clear search input" button. This created an accessibility barrier for keyboard and screen reader users who lost their place in the interface.

Solution: Implemented automatic focus transfer to the clear button after search submission using useEffect to track state transitions. Also removed the key prop that was causing component remounts so that we can preserve the state tracking required for focus management.

Changes:

  • Add clearButtonRef and focus management logic to automatically focus clear button after search submission.
  • Track previous isInputEdited state to detect transitions (prevents unwanted focus on initial render).
  • Remove key={searchTerm} prop from SearchResults - this was causing the component to unmount/remount on every search, which would clear the prevIsInputEdited state and break focus management. Replace remount-based state reset with useEffect for better performance and to preserve component state.

Demo

After

Screen.Recording.2026-01-26.at.18.01.39.mov

@coseeian coseeian requested review from ksen0 and outofambit January 26, 2026 09:58
@coseeian coseeian marked this pull request as ready for review January 26, 2026 10:01
@perminder-17 perminder-17 self-requested a review January 26, 2026 18:21
Copy link
Contributor

@perminder-17 perminder-17 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[focus] Focus is lost after clicking “Submit search” button

2 participants