From 5dd48e1b8668cbaa85fb1aff024ff3c3f03201b4 Mon Sep 17 00:00:00 2001 From: David Wheatley Date: Mon, 20 Sep 2021 16:06:15 +0100 Subject: [PATCH] [A11Y] Accessibility improvements for the Search component (#3017) * Remove deprecated code * Accessibility improvements for Search component --- js/src/forum/components/Search.tsx | 35 ++++++++++++++++---------- less/common/Search.less | 11 ++++++++ less/common/mixins/accessibility.less | 36 +++++++++++++++++++++++++++ locale/core.yml | 2 ++ 4 files changed, 71 insertions(+), 13 deletions(-) diff --git a/js/src/forum/components/Search.tsx b/js/src/forum/components/Search.tsx index e6355a956..b4793eab4 100644 --- a/js/src/forum/components/Search.tsx +++ b/js/src/forum/components/Search.tsx @@ -103,14 +103,18 @@ export default class Search extends Compone const searchLabel = extractText(app.translator.trans('core.forum.header.search_placeholder')); + const isActive = !!currentSearch; + const shouldShowResults = !!(!this.loadingSources && this.state.getValue() && this.hasFocus); + const shouldShowClearButton = !!(!this.loadingSources && this.state.getValue()); + return (
@@ -125,18 +129,23 @@ export default class Search extends Compone onfocus={() => (this.hasFocus = true)} onblur={() => (this.hasFocus = false)} /> - {this.loadingSources ? ( - - ) : currentSearch ? ( - - ) : ( - '' )}
-