Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use announce function in live region #38084

Merged
merged 4 commits into from
Dec 7, 2022

Conversation

nbayati
Copy link
Contributor

@nbayati nbayati commented Dec 5, 2022

Fixes flutter/flutter#108768

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Dec 5, 2022
@nbayati nbayati requested a review from yjbanov December 5, 2022 23:58
_cleanupDom();
// Avoid announcing the same message over and over.
if (_lastAnnouncement != semanticsObject.label)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: leave the open brace on the previous line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

}
}

void _cleanupDom() {
semanticsObject.element.removeAttribute('aria-live');
_lastAnnouncement = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_lastAnnouncement is not a DOM element. It will be garbage-collected automatically. I think we can remove _cleanupDom and the dispose methods, and save a few bytes in payload size.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I have to keep dispose though because otherwise it throws an error about it not being implemented.

semanticsObject.element.setAttribute('aria-live', 'polite');
} else {
_cleanupDom();
// Avoid announcing the same message over and over.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the logic that protects us from announcing the same message again is missing a test. It can be tested by clearing the contents of ariaLiveElementFor(Assertiveness.polite) after the first announcement, issuing an update with the same message, and verifying that the element remains empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our conversation, I implemented a mock class for AccessibilityAnnouncements and added this test case.

@nbayati nbayati requested a review from yjbanov December 6, 2022 03:38
Copy link
Contributor

@yjbanov yjbanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

rect: const ui.Rect.fromLTRB(0, 0, 100, 50),
);
semantics().updateSemantics(builder.build());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I'd add expect(mockAccessibilityAnnouncements.announceInvoked, 1); here too to ensure that the count increases after the first update and then stays stable afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Done!

@nbayati nbayati added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 6, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Dec 6, 2022

auto label is removed for flutter/engine, pr: 38084, due to - The status or check suite Mac Host Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 6, 2022
@nbayati nbayati added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 7, 2022
@auto-submit auto-submit bot merged commit 67254d6 into flutter:main Dec 7, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 7, 2022
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Dec 7, 2022
…116633)

* 5429243d3 [Impeller Scene] Render imported meshes (flutter/engine#38097)

* 67254d6e4 Use announce function in live region (flutter/engine#38084)
shogohida pushed a commit to shogohida/flutter that referenced this pull request Dec 7, 2022
…lutter#116633)

* 5429243d3 [Impeller Scene] Render imported meshes (flutter/engine#38097)

* 67254d6e4 Use announce function in live region (flutter/engine#38084)
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jan 19, 2023
…lutter#116633)

* 5429243d3 [Impeller Scene] Render imported meshes (flutter/engine#38097)

* 67254d6e4 Use announce function in live region (flutter/engine#38084)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flutter-web: Snackbar not read in NVDA screen reader
2 participants