Commit 9019919e authored by Xiaohui Chen's avatar Xiaohui Chen Committed by Commit Bot

assistant: Hide invisible elements to avoid triggering screenreader

When Views are invisible by opacity 0 but still have visibility true,
screenreader would still be able to read it. We need to explicitly
set their visibility to false.

Bug: b:113731925
Test: locally build and not able to navigate to these elements with
Test: screen reader
Change-Id: Ibb1b111844dbd6021c267ef594777614cf127189
Reviewed-on: https://chromium-review.googlesource.com/1212342Reviewed-by: default avatarMuyuan Li <muyuanli@chromium.org>
Commit-Queue: Xiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590085}
parent 5b612ea7
......@@ -146,6 +146,9 @@ void DialogPlate::OnInputModalityChanged(InputModality input_modality) {
using assistant::util::CreateTransformElement;
using assistant::util::StartLayerAnimationSequencesTogether;
keyboard_layout_container_->SetVisible(true);
voice_layout_container_->SetVisible(true);
switch (input_modality) {
case InputModality::kKeyboard: {
// Animate voice layout container opacity to 0%.
......@@ -387,15 +390,16 @@ bool DialogPlate::OnAnimationEnded(
InputModality input_modality = assistant_controller_->interaction_controller()
->model()
->input_modality();
SetFocusMode(input_modality);
SetFocus(input_modality);
switch (input_modality) {
case InputModality::kKeyboard:
keyboard_layout_container_->set_can_process_events_within_subtree(true);
voice_layout_container_->SetVisible(false);
break;
case InputModality::kVoice:
voice_layout_container_->set_can_process_events_within_subtree(true);
keyboard_layout_container_->SetVisible(false);
break;
case InputModality::kStylus:
// No action necessary.
......@@ -420,24 +424,4 @@ void DialogPlate::SetFocus(InputModality input_modality) {
}
}
void DialogPlate::SetFocusMode(InputModality input_modality) {
switch (input_modality) {
case InputModality::kKeyboard:
textfield_->SetFocusBehavior(FocusBehavior::ALWAYS);
voice_input_toggle_->SetFocusBehavior(FocusBehavior::ALWAYS);
keyboard_input_toggle_->SetFocusBehavior(FocusBehavior::NEVER);
animated_voice_input_toggle_->SetFocusBehavior(FocusBehavior::NEVER);
break;
case InputModality::kVoice:
textfield_->SetFocusBehavior(FocusBehavior::NEVER);
voice_input_toggle_->SetFocusBehavior(FocusBehavior::NEVER);
keyboard_input_toggle_->SetFocusBehavior(FocusBehavior::ALWAYS);
animated_voice_input_toggle_->SetFocusBehavior(FocusBehavior::ALWAYS);
break;
case InputModality::kStylus:
// No action necessary.
break;
}
}
} // namespace ash
......@@ -105,7 +105,6 @@ class DialogPlate : public views::View,
bool OnAnimationEnded(const ui::CallbackLayerAnimationObserver& observer);
void SetFocus(InputModality modality);
void SetFocusMode(InputModality modality);
AssistantController* const assistant_controller_; // Owned by Shell.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment