Skip to content

Commit 1c1a538

Browse files
committed
Fix accessible focus on filters refresh.
1 parent 84a4eee commit 1c1a538

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Telegram/SourceFiles/window/window_filters_menu.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,23 @@ void FiltersMenu::refresh() {
364364
// Re-establish the list's Tab-stop on the folder that was focused (if it
365365
// survived the rebuild), else on the active one, so a refresh - rename,
366366
// deletion, Premium-state change - never leaves the list without a Tab-stop.
367+
auto refocus = (Ui::SideBarButton*)nullptr;
367368
if (Ui::ScreenReaderModeActive()) {
368369
auto i = focusedId ? _filters.find(*focusedId) : end(_filters);
369370
if (i == end(_filters)) {
370371
i = _filters.find(_activeFilterId);
371372
}
372373
if (i != end(_filters)) {
373374
setListTabStop(i->second.get());
375+
// setListTabStop only fixes the Tab order; the std::move above
376+
// destroyed the focused button, so Qt also dropped keyboard focus
377+
// (to the menu, the edit button or nowhere). If a folder held it,
378+
// restore focus to the replacement - or the active fallback - below,
379+
// once the scroll is restored, so it lands focused and visible and a
380+
// screen reader keeps reading a folder rather than where focus fell.
381+
if (focusedId) {
382+
refocus = i->second.get();
383+
}
374384
}
375385
}
376386
_reorder->start();
@@ -380,6 +390,11 @@ void FiltersMenu::refresh() {
380390
// After the filters are refreshed, the scroll is reset,
381391
// so we have to restore it.
382392
_scroll.scrollToY(oldTop);
393+
394+
if (refocus) {
395+
refocus->setFocus();
396+
scrollToButton(refocus);
397+
}
383398
}
384399

385400
void FiltersMenu::setupList() {

0 commit comments

Comments
 (0)