mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-06 11:52:58 +00:00
Engaged chat search on typing instead of focus in screen reader mode.
In screen reader mode, focusing the dialogs search field no longer opens the suggestions panel or shows the cancel-search button. Search engages only when the user types, stays engaged after clearing the query, and disengages only on explicit Escape or the cancel-search button. Tab and Backspace on an empty query no longer exit search in this mode. Non-screen-reader behavior is unchanged.
This commit is contained in:
committed by
John Preston
parent
0152fa2aaa
commit
b9aad5d250
@@ -44,6 +44,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "ui/controls/swipe_handler.h"
|
||||
#include "ui/painter.h"
|
||||
#include "ui/rect.h"
|
||||
#include "ui/screen_reader_mode.h"
|
||||
#include "ui/ui_utility.h"
|
||||
#include "lang/lang_keys.h"
|
||||
#include "mainwindow.h"
|
||||
@@ -1773,8 +1774,12 @@ void Widget::processSearchFocusChange() {
|
||||
updateSuggestions(anim::type::normal);
|
||||
}
|
||||
|
||||
bool Widget::searchActive() const {
|
||||
return Ui::ScreenReaderModeActive() ? _searchEngaged : _searchHasFocus;
|
||||
}
|
||||
|
||||
void Widget::updateSuggestions(anim::type animated) {
|
||||
const auto suggest = (_searchHasFocus || _searchSuggestionsLocked)
|
||||
const auto suggest = (searchActive() || _searchSuggestionsLocked)
|
||||
&& !_searchState.inChat
|
||||
&& (_inner->state() == WidgetState::Default);
|
||||
if (anim::Disabled() || !session().data().chatsListLoaded()) {
|
||||
@@ -3363,7 +3368,7 @@ void Widget::listScrollUpdated() {
|
||||
void Widget::updateCancelSearch() {
|
||||
const auto shown = !_searchState.query.isEmpty()
|
||||
|| (!_searchState.inChat
|
||||
&& (_searchHasFocus || _searchSuggestionsLocked));
|
||||
&& (searchActive() || _searchSuggestionsLocked));
|
||||
_cancelSearch->toggle(shown, anim::type::normal);
|
||||
if (_searchState.inChat) {
|
||||
_cancelSearch->setAccessibleName(shown
|
||||
@@ -3400,6 +3405,9 @@ QString Widget::validateSearchQuery() {
|
||||
void Widget::applySearchUpdate() {
|
||||
auto copy = _searchState;
|
||||
copy.query = validateSearchQuery();
|
||||
if (Ui::ScreenReaderModeActive() && !copy.query.isEmpty()) {
|
||||
_searchEngaged = true;
|
||||
}
|
||||
applySearchState(std::move(copy));
|
||||
|
||||
if (_chooseFromUser->toggled()
|
||||
@@ -4173,7 +4181,8 @@ void Widget::keyPressEvent(QKeyEvent *e) {
|
||||
//} else {
|
||||
// e->ignore();
|
||||
//}
|
||||
} else if ((e->key() == Qt::Key_Backspace || e->key() == Qt::Key_Tab)
|
||||
} else if ((e->key() == Qt::Key_Backspace
|
||||
|| (e->key() == Qt::Key_Tab && !Ui::ScreenReaderModeActive()))
|
||||
&& _searchHasFocus
|
||||
&& !_searchState.inChat
|
||||
&& _searchState.query.isEmpty()) {
|
||||
@@ -4404,6 +4413,7 @@ void Widget::setSearchQuery(const QString &query, int cursorPosition) {
|
||||
}
|
||||
|
||||
bool Widget::cancelSearch(CancelSearchOptions options) {
|
||||
_searchEngaged = false;
|
||||
const auto clearingSuggestionsQuery = _suggestions
|
||||
&& _suggestions->consumeSearchQuery(QString());
|
||||
if (clearingSuggestionsQuery) {
|
||||
|
||||
Reference in New Issue
Block a user