Skip to content

Refactor search bars + improve search accessibility#1608

Open
zoeyAhmed wants to merge 9 commits into
bazaar-org:mainfrom
zoeyAhmed:fix-search-accessibility
Open

Refactor search bars + improve search accessibility#1608
zoeyAhmed wants to merge 9 commits into
bazaar-org:mainfrom
zoeyAhmed:fix-search-accessibility

Conversation

@zoeyAhmed

@zoeyAhmed zoeyAhmed commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Draft because theres an issue with focusing the search bar causing it to somehow draw focus rings around both the end-child and the search bar when focusing into the search bar, and I need to run clang-format again.

This MR fixes quite a few of the issues I found with both keyboard navigation + screen readers I found within Bazaar

  • The search bars did not read out their placeholder text when focused, and not containing any text
  • Ctrl+F focused the last widget and not the search bar when the search page is presented
  • Bazaar did not read out the number of search results to the screen reader.

Before:

Bazaar-before-search-tweaks.mp4

After:

Bazaar-after-search-tweaks.mp4

@zoeyAhmed zoeyAhmed force-pushed the fix-search-accessibility branch from f872110 to 6390721 Compare June 9, 2026 18:09
@AlexanderVanhee

AlexanderVanhee commented Jun 13, 2026

Copy link
Copy Markdown
Collaborator

I fixed the double focus thing, but I can't push to this, so here is the patch file.

fix-search-focus.patch

This widget is similar to GtkSearchEntry, but with 2 extra properties to
provide a spinner and end widget, which the bar in the search page
needs, and only providing a signal for search changed, rather then
search started/end.

BzSearchBar implements GtkEditable and GtkAccessible, to provide
accessible semantics for the top level widget, by overriding
`Gtk.Accessible.get_platform_state ()` to return the platform state of
the GtkText contained within. This fixes an issue with Bazaar's search
bars not announcing the placeholder text if they are currently empty.
Since we are using a BoxLayout in BzSearchBar with spacing 8, the extra
padding is not necessary anymore
Override `GtkWidgetClass.grab_focus`, and use that to grab focus in
`ensure_active` to grab focus on the search bar immediately, even when
no text has been entered. This is desirable to the previous behaviour so
the screen reader will always read out the placeholder text of the
search bar, instead of
focusing on the previously foucsed widget, which may not be the search
bar and will just read out its tooltip
For whatever reason, both the end item and the search bar would display
focus rings when re-entering the search bar using Shift+Tab

As a workaround, use an event widget focus controller to apply/remove
custom CSS to hide the focus ring around the search bar if the end
widget is focused

Co-authored-by: Alexander Vanhee
Without the override, using Shift+Tab or Up, while focused on the search
bar, will not move the focus away from the search bar, so as a
workaround, wrap the search texts focus method in the search bar focus
override
@zoeyAhmed zoeyAhmed force-pushed the fix-search-accessibility branch from 6390721 to 62c3972 Compare June 30, 2026 10:35
@zoeyAhmed zoeyAhmed marked this pull request as ready for review June 30, 2026 10:36
@zoeyAhmed zoeyAhmed requested a review from kolunmi as a code owner June 30, 2026 10:36
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.

2 participants