Skip to content

Commit

Permalink
[web_ui] Fixed aria-live attribute on web (flutter#27985)
Browse files Browse the repository at this point in the history
* Fixed aria-live attribute on web
  • Loading branch information
The one with the braid | Dфҿ mit dem Zopf authored Aug 10, 2021
1 parent 7ec35b0 commit d8bbebe
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Hidenori Matsubayashi <[email protected]>
Sarbagya Dhaubanjar <[email protected]>
Callum Moffat <[email protected]>
Koutaro Mori <[email protected]>
TheOneWithTheBraid <[email protected]>
8 changes: 5 additions & 3 deletions lib/web_ui/lib/src/engine/semantics/semantics_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ class DesktopSemanticsEnabler extends SemanticsEnabler {

@override
html.Element prepareAccessibilityPlaceholder() {
final html.Element placeholder = _semanticsPlaceholder = html.Element.tag('flt-semantics-placeholder');
final html.Element placeholder =
_semanticsPlaceholder = html.Element.tag('flt-semantics-placeholder');

// Only listen to "click" because other kinds of events are reported via
// PointerBinding.
Expand All @@ -189,7 +190,7 @@ class DesktopSemanticsEnabler extends SemanticsEnabler {
// to the assistive technology user.
placeholder
..setAttribute('role', 'button')
..setAttribute('aria-live', 'true')
..setAttribute('aria-live', 'polite')
..setAttribute('tabindex', '0')
..setAttribute('aria-label', placeholderMessage);

Expand Down Expand Up @@ -372,7 +373,8 @@ class MobileSemanticsEnabler extends SemanticsEnabler {

@override
html.Element prepareAccessibilityPlaceholder() {
final html.Element placeholder = _semanticsPlaceholder = html.Element.tag('flt-semantics-placeholder');
final html.Element placeholder =
_semanticsPlaceholder = html.Element.tag('flt-semantics-placeholder');

// Only listen to "click" because other kinds of events are reported via
// PointerBinding.
Expand Down
12 changes: 6 additions & 6 deletions lib/web_ui/test/engine/semantics/semantics_helper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ void testMain() {
EngineSemanticsOwner.instance.semanticsEnabled = false;
});

test('prepare accesibility placeholder', () async {
test('prepare accessibility placeholder', () async {
expect(_placeholder!.getAttribute('role'), 'button');
expect(_placeholder!.getAttribute('aria-live'), 'true');
expect(_placeholder!.getAttribute('aria-live'), 'polite');
expect(_placeholder!.getAttribute('tabindex'), '0');

html.document.body!.append(_placeholder!);
Expand Down Expand Up @@ -72,7 +72,7 @@ void testMain() {
});

test(
'Relevants events targeting placeholder should not be forwarded to the framework',
'Relevant events targeting placeholder should not be forwarded to the framework',
() async {
final html.Event event = html.MouseEvent('mousedown');
_placeholder!.dispatchEvent(event);
Expand Down Expand Up @@ -110,15 +110,15 @@ void testMain() {
EngineSemanticsOwner.instance.semanticsEnabled = false;
});

test('prepare accesibility placeholder', () async {
test('prepare accessibility placeholder', () async {
expect(_placeholder!.getAttribute('role'), 'button');

// Placeholder should cover all the screen on a mobile device.
final num bodyHeight = html.window.innerHeight!;
final num bodyWidht = html.window.innerWidth!;
final num bodyWidth = html.window.innerWidth!;

expect(_placeholder!.getBoundingClientRect().height, bodyHeight);
expect(_placeholder!.getBoundingClientRect().width, bodyWidht);
expect(_placeholder!.getBoundingClientRect().width, bodyWidth);
});

test('Non-relevant events should be forwarded to the framework',
Expand Down

0 comments on commit d8bbebe

Please sign in to comment.