[framework] Fix Text.semanticsIdentifier being absorbed by ancestor nodes#181795
Conversation
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where the semanticsIdentifier of a Text widget was being absorbed by ancestor semantic nodes. The fix correctly sets container: true on the Semantics widget wrapper when a semanticsIdentifier is provided, ensuring a new semantic node is created. The change is accompanied by thorough regression tests that verify the fix in both a simple case and within a Dialog widget, confirming that the identifier is no longer absorbed. The implementation is clean and the tests are well-written. I have no further suggestions.
| identifier: semanticsIdentifier, | ||
| // Fix for issue #180894: When semanticsIdentifier is provided, set container: true | ||
| // to prevent the identifier from being absorbed into ancestor semantic nodes. | ||
| container: semanticsIdentifier != null, |
There was a problem hiding this comment.
semanticsIdentifier IIRC is mostly for unittest and uiautomation test, letting it change tree shape seems weird. This seems a bit drastic to fix the root cause, i.e. dialog role ignored semantics identifier.
There was a problem hiding this comment.
@chunhtai we could look at semanticsIdentifier as being a signal from the user wanting to have a reference to this semantics node, so we should not merge it up.
That being said, if we decide to go this route, the fix should be more general, not only for the Text widget.
There was a problem hiding this comment.
Make fix more general at SemanticsConfiguration level. Please review.
| if (_maxValue != null && other._maxValue != null) { | ||
| return false; | ||
| } | ||
| if (other._identifier.isNotEmpty) { |
There was a problem hiding this comment.
We don't promise how this is called, for example other may be the parent, child, or sibling. but this code will depends on how the api is called to do the right thing.
I assume the intention is that we are ok if a child merge to a "parent that has identifier", but disallows a "child that has identifer" to merge to parent? the code here will fail if we somehow do child.isCompatableWith(parent).
We may need find a different way around it.
There was a problem hiding this comment.
Good catch. I've updated the logic. Now when identifier is set, isSemanticBoundary is set to true, which forces a dedicated SemanticsNode before merging is even considered. This avoids the isCompatibleWith directionality issue entirely.
chunhtai
left a comment
There was a problem hiding this comment.
LGTM, just some minor comments
| void describeSemanticsConfiguration(SemanticsConfiguration config) { | ||
| super.describeSemanticsConfiguration(config); | ||
| config.isSemanticBoundary = container; | ||
| config.isSemanticBoundary = container || (_properties.identifier != null); |
There was a problem hiding this comment.
can you also update the doc for _SemanticsBase.container and SemanticsProperty.identifier to mention this behavior?
There was a problem hiding this comment.
also this may be a potential breaking change even if it is not breaking customer test, so should watchout after merge.
There was a problem hiding this comment.
- I updated the docs.
- Good point. I'll keep an eye on it after landing.
Roll Flutter from 1141b2bdce66 to 46fb7210422d (38 revisions) flutter/flutter@1141b2b...46fb721 2026-03-02 parlough@gmail.com [rules] Fix a few issues in the full-length rules file (flutter/flutter#182725) 2026-03-02 engine-flutter-autoroll@skia.org Roll Dart SDK from 8063f5f5ac60 to e86dbe9aa742 (1 revision) (flutter/flutter#183120) 2026-03-02 mdebbar@google.com [web] Roll Chrome to 145 (flutter/flutter#182860) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from 61c0e71760f5 to e180358b7a7a (1 revision) (flutter/flutter#183118) 2026-03-02 engine-flutter-autoroll@skia.org Roll Packages from a27d7c5 to faa4e22 (4 revisions) (flutter/flutter#183117) 2026-03-02 stuartmorgan@google.com Add information to issue triage page (flutter/flutter#182145) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from cc8ce92481f2 to 61c0e71760f5 (2 revisions) (flutter/flutter#183103) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from 4cf3cd27b620 to cc8ce92481f2 (1 revision) (flutter/flutter#183100) 2026-03-02 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from zN2ZV9QD0LD8acUFF... to 0dCDM2oORHwDf_pyb... (flutter/flutter#183101) 2026-03-01 nick.fisher@avinium.com Update fl_texture_gl.h (flutter/flutter#182999) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from be1362b5ca4e to 4cf3cd27b620 (1 revision) (flutter/flutter#183096) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from b9210eb7005f to be1362b5ca4e (1 revision) (flutter/flutter#183092) 2026-03-01 robert.ancell@canonical.com Timeout when waiting for the correct sized frame from Flutter. (flutter/flutter#182971) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from 28172a4e03af to b9210eb7005f (1 revision) (flutter/flutter#183088) 2026-03-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from D7IYacJUCpvc_1iU_... to zN2ZV9QD0LD8acUFF... (flutter/flutter#183076) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from cdf45eaf995e to 8063f5f5ac60 (1 revision) (flutter/flutter#183064) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 54451fcdbcf9 to cdf45eaf995e (1 revision) (flutter/flutter#183057) 2026-02-28 engine-flutter-autoroll@skia.org Roll Skia from c8bcc27f5319 to 28172a4e03af (3 revisions) (flutter/flutter#183056) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 148d91b8a603 to 54451fcdbcf9 (2 revisions) (flutter/flutter#183051) 2026-02-28 jhy03261997@gmail.com [A11y] in calendar date picker, remove SemanticsService.sendAnnouncement usage for android. (flutter/flutter#182918) 2026-02-28 737941+loic-sharma@users.noreply.github.com Add desktop review teams (flutter/flutter#182972) 2026-02-28 zhongliu88889@gmail.com [framework] Fix Text.semanticsIdentifier being absorbed by ancestor nodes (flutter/flutter#181795) 2026-02-28 engine-flutter-autoroll@skia.org Roll Skia from b150186d3e23 to c8bcc27f5319 (5 revisions) (flutter/flutter#183032) 2026-02-28 jason-simmons@users.noreply.github.com [Impeller] For Android hardware buffers on Vulkan, use an alpha value of 1 if the buffer format always has opaque alpha (flutter/flutter#182974) 2026-02-27 30870216+gaaclarke@users.noreply.github.com Adds float32 output to `Image.toByteData()` in float32 Image (flutter/flutter#182847) 2026-02-27 engine-flutter-autoroll@skia.org Roll Dart SDK from 1cdb7dfd913e to 148d91b8a603 (1 revision) (flutter/flutter#183025) 2026-02-27 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from G1GwOdVt5bM7GjMSY... to D7IYacJUCpvc_1iU_... (flutter/flutter#183021) 2026-02-27 97480502+b-luk@users.noreply.github.com When impellerc fails with a long shader compilation error, truncate it and output to a file (flutter/flutter#182786) 2026-02-27 15619084+vashworth@users.noreply.github.com Add missing mutation-safe delegate iteration and use idomatic syntax (flutter/flutter#183018) 2026-02-27 15619084+vashworth@users.noreply.github.com Exclude arm64 if any dependencies do and print warning when using Xcode 26 (flutter/flutter#182913) 2026-02-27 victorsanniay@gmail.com Ignore unawaited_futures lint in dev/automated_tests (flutter/flutter#182922) 2026-02-27 30870216+gaaclarke@users.noreply.github.com licenses_cpp: pre-land changes for perfetto update (flutter/flutter#182965) 2026-02-27 15619084+vashworth@users.noreply.github.com Re-add extended attribute removed by SwiftPM (flutter/flutter#183011) 2026-02-27 52160996+FMorschel@users.noreply.github.com Fixes future warning for `await`ing `Future` returns in `async` bodies inside `try` blocks (flutter/flutter#182301) 2026-02-27 engine-flutter-autoroll@skia.org Roll Skia from ed220c490eea to b150186d3e23 (2 revisions) (flutter/flutter#183014) 2026-02-27 51901607+O-Hannonen@users.noreply.github.com Fix issue where web embedder is synthesizing key up events too eagerly (flutter/flutter#180692) 2026-02-27 1961493+harryterkelsen@users.noreply.github.com chore: Don't unconditionally check tools/gn formatting (flutter/flutter#182973) 2026-02-27 engine-flutter-autoroll@skia.org Roll Packages from e1d0169 to a27d7c5 (8 revisions) (flutter/flutter#183009) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose ...
…odes (flutter#181795) Problem: Text widget's semanticsIdentifier was being absorbed into ancestor semantic nodes (like Dialog) instead of creating its own semantic element. Root Cause: The Semantics wrapper in Text didn't set container: true, allowing the identifier to be merged upward during semantics tree construction. Fix: Added container: semanticsIdentifier != null to the Text widget's Semantics wrapper. Fixes flutter#180894. Before https://flutter-demo-11-before.web.app/ After https://flutter-demo-11-after.web.app/
…r#11162) Roll Flutter from 1141b2bdce66 to 46fb7210422d (38 revisions) flutter/flutter@1141b2b...46fb721 2026-03-02 parlough@gmail.com [rules] Fix a few issues in the full-length rules file (flutter/flutter#182725) 2026-03-02 engine-flutter-autoroll@skia.org Roll Dart SDK from 8063f5f5ac60 to e86dbe9aa742 (1 revision) (flutter/flutter#183120) 2026-03-02 mdebbar@google.com [web] Roll Chrome to 145 (flutter/flutter#182860) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from 61c0e71760f5 to e180358b7a7a (1 revision) (flutter/flutter#183118) 2026-03-02 engine-flutter-autoroll@skia.org Roll Packages from a27d7c5 to faa4e22 (4 revisions) (flutter/flutter#183117) 2026-03-02 stuartmorgan@google.com Add information to issue triage page (flutter/flutter#182145) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from cc8ce92481f2 to 61c0e71760f5 (2 revisions) (flutter/flutter#183103) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from 4cf3cd27b620 to cc8ce92481f2 (1 revision) (flutter/flutter#183100) 2026-03-02 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from zN2ZV9QD0LD8acUFF... to 0dCDM2oORHwDf_pyb... (flutter/flutter#183101) 2026-03-01 nick.fisher@avinium.com Update fl_texture_gl.h (flutter/flutter#182999) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from be1362b5ca4e to 4cf3cd27b620 (1 revision) (flutter/flutter#183096) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from b9210eb7005f to be1362b5ca4e (1 revision) (flutter/flutter#183092) 2026-03-01 robert.ancell@canonical.com Timeout when waiting for the correct sized frame from Flutter. (flutter/flutter#182971) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from 28172a4e03af to b9210eb7005f (1 revision) (flutter/flutter#183088) 2026-03-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from D7IYacJUCpvc_1iU_... to zN2ZV9QD0LD8acUFF... (flutter/flutter#183076) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from cdf45eaf995e to 8063f5f5ac60 (1 revision) (flutter/flutter#183064) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 54451fcdbcf9 to cdf45eaf995e (1 revision) (flutter/flutter#183057) 2026-02-28 engine-flutter-autoroll@skia.org Roll Skia from c8bcc27f5319 to 28172a4e03af (3 revisions) (flutter/flutter#183056) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 148d91b8a603 to 54451fcdbcf9 (2 revisions) (flutter/flutter#183051) 2026-02-28 jhy03261997@gmail.com [A11y] in calendar date picker, remove SemanticsService.sendAnnouncement usage for android. (flutter/flutter#182918) 2026-02-28 737941+loic-sharma@users.noreply.github.com Add desktop review teams (flutter/flutter#182972) 2026-02-28 zhongliu88889@gmail.com [framework] Fix Text.semanticsIdentifier being absorbed by ancestor nodes (flutter/flutter#181795) 2026-02-28 engine-flutter-autoroll@skia.org Roll Skia from b150186d3e23 to c8bcc27f5319 (5 revisions) (flutter/flutter#183032) 2026-02-28 jason-simmons@users.noreply.github.com [Impeller] For Android hardware buffers on Vulkan, use an alpha value of 1 if the buffer format always has opaque alpha (flutter/flutter#182974) 2026-02-27 30870216+gaaclarke@users.noreply.github.com Adds float32 output to `Image.toByteData()` in float32 Image (flutter/flutter#182847) 2026-02-27 engine-flutter-autoroll@skia.org Roll Dart SDK from 1cdb7dfd913e to 148d91b8a603 (1 revision) (flutter/flutter#183025) 2026-02-27 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from G1GwOdVt5bM7GjMSY... to D7IYacJUCpvc_1iU_... (flutter/flutter#183021) 2026-02-27 97480502+b-luk@users.noreply.github.com When impellerc fails with a long shader compilation error, truncate it and output to a file (flutter/flutter#182786) 2026-02-27 15619084+vashworth@users.noreply.github.com Add missing mutation-safe delegate iteration and use idomatic syntax (flutter/flutter#183018) 2026-02-27 15619084+vashworth@users.noreply.github.com Exclude arm64 if any dependencies do and print warning when using Xcode 26 (flutter/flutter#182913) 2026-02-27 victorsanniay@gmail.com Ignore unawaited_futures lint in dev/automated_tests (flutter/flutter#182922) 2026-02-27 30870216+gaaclarke@users.noreply.github.com licenses_cpp: pre-land changes for perfetto update (flutter/flutter#182965) 2026-02-27 15619084+vashworth@users.noreply.github.com Re-add extended attribute removed by SwiftPM (flutter/flutter#183011) 2026-02-27 52160996+FMorschel@users.noreply.github.com Fixes future warning for `await`ing `Future` returns in `async` bodies inside `try` blocks (flutter/flutter#182301) 2026-02-27 engine-flutter-autoroll@skia.org Roll Skia from ed220c490eea to b150186d3e23 (2 revisions) (flutter/flutter#183014) 2026-02-27 51901607+O-Hannonen@users.noreply.github.com Fix issue where web embedder is synthesizing key up events too eagerly (flutter/flutter#180692) 2026-02-27 1961493+harryterkelsen@users.noreply.github.com chore: Don't unconditionally check tools/gn formatting (flutter/flutter#182973) 2026-02-27 engine-flutter-autoroll@skia.org Roll Packages from e1d0169 to a27d7c5 (8 revisions) (flutter/flutter#183009) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose ...
…odes (flutter#181795) Problem: Text widget's semanticsIdentifier was being absorbed into ancestor semantic nodes (like Dialog) instead of creating its own semantic element. Root Cause: The Semantics wrapper in Text didn't set container: true, allowing the identifier to be merged upward during semantics tree construction. Fix: Added container: semanticsIdentifier != null to the Text widget's Semantics wrapper. Fixes flutter#180894. Before https://flutter-demo-11-before.web.app/ After https://flutter-demo-11-after.web.app/
…r#11162) Roll Flutter from 1141b2bdce66 to 46fb7210422d (38 revisions) flutter/flutter@1141b2b...46fb721 2026-03-02 parlough@gmail.com [rules] Fix a few issues in the full-length rules file (flutter/flutter#182725) 2026-03-02 engine-flutter-autoroll@skia.org Roll Dart SDK from 8063f5f5ac60 to e86dbe9aa742 (1 revision) (flutter/flutter#183120) 2026-03-02 mdebbar@google.com [web] Roll Chrome to 145 (flutter/flutter#182860) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from 61c0e71760f5 to e180358b7a7a (1 revision) (flutter/flutter#183118) 2026-03-02 engine-flutter-autoroll@skia.org Roll Packages from a27d7c5 to faa4e22 (4 revisions) (flutter/flutter#183117) 2026-03-02 stuartmorgan@google.com Add information to issue triage page (flutter/flutter#182145) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from cc8ce92481f2 to 61c0e71760f5 (2 revisions) (flutter/flutter#183103) 2026-03-02 engine-flutter-autoroll@skia.org Roll Skia from 4cf3cd27b620 to cc8ce92481f2 (1 revision) (flutter/flutter#183100) 2026-03-02 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from zN2ZV9QD0LD8acUFF... to 0dCDM2oORHwDf_pyb... (flutter/flutter#183101) 2026-03-01 nick.fisher@avinium.com Update fl_texture_gl.h (flutter/flutter#182999) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from be1362b5ca4e to 4cf3cd27b620 (1 revision) (flutter/flutter#183096) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from b9210eb7005f to be1362b5ca4e (1 revision) (flutter/flutter#183092) 2026-03-01 robert.ancell@canonical.com Timeout when waiting for the correct sized frame from Flutter. (flutter/flutter#182971) 2026-03-01 engine-flutter-autoroll@skia.org Roll Skia from 28172a4e03af to b9210eb7005f (1 revision) (flutter/flutter#183088) 2026-03-01 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from D7IYacJUCpvc_1iU_... to zN2ZV9QD0LD8acUFF... (flutter/flutter#183076) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from cdf45eaf995e to 8063f5f5ac60 (1 revision) (flutter/flutter#183064) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 54451fcdbcf9 to cdf45eaf995e (1 revision) (flutter/flutter#183057) 2026-02-28 engine-flutter-autoroll@skia.org Roll Skia from c8bcc27f5319 to 28172a4e03af (3 revisions) (flutter/flutter#183056) 2026-02-28 engine-flutter-autoroll@skia.org Roll Dart SDK from 148d91b8a603 to 54451fcdbcf9 (2 revisions) (flutter/flutter#183051) 2026-02-28 jhy03261997@gmail.com [A11y] in calendar date picker, remove SemanticsService.sendAnnouncement usage for android. (flutter/flutter#182918) 2026-02-28 737941+loic-sharma@users.noreply.github.com Add desktop review teams (flutter/flutter#182972) 2026-02-28 zhongliu88889@gmail.com [framework] Fix Text.semanticsIdentifier being absorbed by ancestor nodes (flutter/flutter#181795) 2026-02-28 engine-flutter-autoroll@skia.org Roll Skia from b150186d3e23 to c8bcc27f5319 (5 revisions) (flutter/flutter#183032) 2026-02-28 jason-simmons@users.noreply.github.com [Impeller] For Android hardware buffers on Vulkan, use an alpha value of 1 if the buffer format always has opaque alpha (flutter/flutter#182974) 2026-02-27 30870216+gaaclarke@users.noreply.github.com Adds float32 output to `Image.toByteData()` in float32 Image (flutter/flutter#182847) 2026-02-27 engine-flutter-autoroll@skia.org Roll Dart SDK from 1cdb7dfd913e to 148d91b8a603 (1 revision) (flutter/flutter#183025) 2026-02-27 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from G1GwOdVt5bM7GjMSY... to D7IYacJUCpvc_1iU_... (flutter/flutter#183021) 2026-02-27 97480502+b-luk@users.noreply.github.com When impellerc fails with a long shader compilation error, truncate it and output to a file (flutter/flutter#182786) 2026-02-27 15619084+vashworth@users.noreply.github.com Add missing mutation-safe delegate iteration and use idomatic syntax (flutter/flutter#183018) 2026-02-27 15619084+vashworth@users.noreply.github.com Exclude arm64 if any dependencies do and print warning when using Xcode 26 (flutter/flutter#182913) 2026-02-27 victorsanniay@gmail.com Ignore unawaited_futures lint in dev/automated_tests (flutter/flutter#182922) 2026-02-27 30870216+gaaclarke@users.noreply.github.com licenses_cpp: pre-land changes for perfetto update (flutter/flutter#182965) 2026-02-27 15619084+vashworth@users.noreply.github.com Re-add extended attribute removed by SwiftPM (flutter/flutter#183011) 2026-02-27 52160996+FMorschel@users.noreply.github.com Fixes future warning for `await`ing `Future` returns in `async` bodies inside `try` blocks (flutter/flutter#182301) 2026-02-27 engine-flutter-autoroll@skia.org Roll Skia from ed220c490eea to b150186d3e23 (2 revisions) (flutter/flutter#183014) 2026-02-27 51901607+O-Hannonen@users.noreply.github.com Fix issue where web embedder is synthesizing key up events too eagerly (flutter/flutter#180692) 2026-02-27 1961493+harryterkelsen@users.noreply.github.com chore: Don't unconditionally check tools/gn formatting (flutter/flutter#182973) 2026-02-27 engine-flutter-autoroll@skia.org Roll Packages from e1d0169 to a27d7c5 (8 revisions) (flutter/flutter#183009) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC bmparr@google.com,stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose ...
Problem: Text widget's semanticsIdentifier was being absorbed into ancestor semantic nodes (like Dialog) instead of creating its own semantic element.
Root Cause: The Semantics wrapper in Text didn't set container: true, allowing the identifier to be merged upward during semantics tree construction.
Fix: Added container: semanticsIdentifier != null to the Text widget's Semantics wrapper.
Fixes #180894.
Before
https://flutter-demo-11-before.web.app/
After
https://flutter-demo-11-after.web.app/