-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Fix table cell semantics rect alignment issues. #174914
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
Fix table cell semantics rect alignment issues. #174914
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses an issue with table cell semantics rect alignment by correctly using the cell's bottom edge for overflow checks, which is a definite improvement. A regression test has been added to cover this fix. I've included one comment with a suggestion to make the new test more robust by covering the specific failing condition described in the original issue.
| testWidgets('DataTable cell has correct semantics rect ', (WidgetTester tester) async { | ||
| final SemanticsTester semantics = SemanticsTester(tester); | ||
| await tester.pumpWidget( | ||
| MaterialApp( | ||
| home: Scaffold( | ||
| body: DataTable( | ||
| columns: const <DataColumn>[ | ||
| // Set width so the Column width is not determined by text. | ||
| DataColumn(label: SizedBox(width: 250, child: Text('Column 1'))), | ||
| DataColumn(label: SizedBox(width: 250, child: Text('Column 2'))), | ||
| ], | ||
| rows: const <DataRow>[ | ||
| DataRow( | ||
| cells: <DataCell>[DataCell(Text('Data Cell 1')), DataCell(Text('Data Cell 2'))], | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| final TestSemantics expectedSemantics = TestSemantics.root( | ||
| children: <TestSemantics>[ | ||
| TestSemantics.rootChild( | ||
| id: 1, | ||
| textDirection: TextDirection.ltr, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| id: 2, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| id: 3, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), | ||
| flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| id: 4, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 604.0, 104.0), | ||
| role: SemanticsRole.table, | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| id: 9, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 604.0, 56.0), | ||
| role: SemanticsRole.row, | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| id: 5, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 302.0, 56.0), | ||
| label: 'Column 1', | ||
| textDirection: TextDirection.ltr, | ||
| role: SemanticsRole.columnHeader, | ||
| ), | ||
| TestSemantics( | ||
| id: 6, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 302.0, 56.0), | ||
| transform: Matrix4.translationValues(302, 0, 0), | ||
| label: 'Column 2', | ||
| textDirection: TextDirection.ltr, | ||
| role: SemanticsRole.columnHeader, | ||
| ), | ||
| ], | ||
| ), | ||
| TestSemantics( | ||
| id: 10, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 604.0, 48.0), | ||
| transform: Matrix4.translationValues(0, 56, 0), | ||
| role: SemanticsRole.row, | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| id: 7, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 302.0, 48.0), | ||
| label: 'Data Cell 1', | ||
| textDirection: TextDirection.ltr, | ||
| role: SemanticsRole.cell, | ||
| ), | ||
| TestSemantics( | ||
| id: 8, | ||
| rect: const Rect.fromLTRB(0.0, 0.0, 302.0, 48.0), | ||
| transform: Matrix4.translationValues(302, 0, 0), | ||
| label: 'Data Cell 2', | ||
| textDirection: TextDirection.ltr, | ||
| role: SemanticsRole.cell, | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ); | ||
|
|
||
| expect(semantics, hasSemantics(expectedSemantics)); | ||
|
|
||
| semantics.dispose(); | ||
| }); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will trigger the failure in #171264 because cell height is bigger than column header height
| ), | ||
| ); | ||
|
|
||
| final TestSemantics expectedSemantics = TestSemantics.root( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to just only check the semantics node of interests. This type of test is very noise when change semantics tree shape for unrelated reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated tests
f43591c to
9cb3777
Compare
chunhtai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Roll Flutter from 6b18740d5a23 to 87d5b753196c (88 revisions) flutter/flutter@6b18740...87d5b75 2025-09-05 bkonyi@google.com [ Device Lab ] Add regression testing for flutter/flutter#174952 (flutter/flutter#174956) 2025-09-05 engine-flutter-autoroll@skia.org Roll Skia from 0ca53adfc6cc to 845ec125e94c (2 revisions) (flutter/flutter#174978) 2025-09-05 bruno.leroux@gmail.com [a11y-app] Fix NavigationRail leading and trailing labels (flutter/flutter#174861) 2025-09-05 engine-flutter-autoroll@skia.org Roll Skia from d7e99be07d5d to 0ca53adfc6cc (5 revisions) (flutter/flutter#174972) 2025-09-05 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from izfNA3o_2zL4Cjqmy... to xG_uERsxHvUwFHpF2... (flutter/flutter#174970) 2025-09-04 bruno.leroux@gmail.com Fix IconButton.color overrided by IconButtomTheme (flutter/flutter#174515) 2025-09-04 mdebbar@google.com [web] Reuse chrome instance to run all flutter tests (flutter/flutter#174957) 2025-09-04 pedromassango.developer@gmail.com fix(Semantics): Ensure semantics properties take priority over button's (flutter/flutter#174473) 2025-09-04 15619084+vashworth@users.noreply.github.com Make every LLDB Init error message actionable (flutter/flutter#174726) 2025-09-04 jhy03261997@gmail.com Fix table cell semantics rect alignment issues. (flutter/flutter#174914) 2025-09-04 34465683+rkishan516@users.noreply.github.com Fix: Use route navigator for CupertinoSheetRoute pop (flutter/flutter#173103) 2025-09-04 bkonyi@google.com [ Widget Preview] Add `group` property to `Preview` (flutter/flutter#174849) 2025-09-04 47866232+chunhtai@users.noreply.github.com Allow OverlayPortal.overlayChildLayoutBuilder to choose root Overlay (flutter/flutter#174239) 2025-09-04 engine-flutter-autoroll@skia.org Roll Skia from 7c2f502e3304 to d7e99be07d5d (18 revisions) (flutter/flutter#174936) 2025-09-04 mdebbar@google.com Remove 'terms of use' wording from web_unicode (flutter/flutter#174939) 2025-09-04 bkonyi@google.com [ Tool ] Remove leftover Android x86 deprecation warning constant (flutter/flutter#174941) 2025-09-04 15619084+vashworth@users.noreply.github.com Prevent potential crash when accessing window in FlutterSceneDelegate (flutter/flutter#174873) 2025-09-04 engine-flutter-autoroll@skia.org Roll Packages from 42bb347 to 98580c6 (5 revisions) (flutter/flutter#174943) 2025-09-04 bkonyi@google.com [ Device Lab ] Fix wakefulness check to only match log entries with string values (flutter/flutter#174953) 2025-09-04 bruno.leroux@gmail.com Fix expanded DropdownMenu panel is shorter than text field (flutter/flutter#174443) 2025-09-04 31859944+LongCatIsLooong@users.noreply.github.com Add a `viewController` property to the ios/macOS `FlutterPluginRegistrar` protocol (flutter/flutter#174168) 2025-09-03 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from J3T_wZqL_57mRfWky... to izfNA3o_2zL4Cjqmy... (flutter/flutter#174908) 2025-09-03 47866232+chunhtai@users.noreply.github.com Wires up Android API to set section locale (flutter/flutter#173364) 2025-09-03 chinmaygarde@google.com Delete impeller::SPrintF. (flutter/flutter#174900) 2025-09-03 ahmedsameha1@gmail.com Make sure that a DropdownMenuFormField doesn't crash in 0x0 environment (flutter/flutter#174777) 2025-09-03 mdebbar@google.com Remove unnecessary `presubmit_max_attempts` from .ci.yaml (flutter/flutter#174885) 2025-09-03 mdebbar@google.com Use local canvaskit in `dart_data_asset_test.dart` (flutter/flutter#174891) 2025-09-03 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Mark Linux web_canvaskit_tests_7_last as bringup (#174878)" (flutter/flutter#174897) 2025-09-03 victorsanniay@gmail.com Correct intrinsics calculation for CupertinoTextField with placeholder (flutter/flutter#174889) 2025-09-03 11901536+romaingyh@users.noreply.github.com Considers large title height in CupertinoNavigationBar's preferred size (flutter/flutter#173722) 2025-09-03 victorsanniay@gmail.com [A11y] Add semantics for CupertinoExpansionTile (flutter/flutter#174480) 2025-09-03 sokolovskyi.konstantin@gmail.com Fix LinearProgressIndicator track painting. (flutter/flutter#173108) 2025-09-03 matt.boetger@gmail.com update triage documentation to include team-android (flutter/flutter#174850) 2025-09-03 mdebbar@google.com Update `test_timeout_secs` to match `timeout` for `Linux web_skwasm_tests_*` and `Linux web_canvaskit_tests_*` (flutter/flutter#174881) 2025-09-03 engine-flutter-autoroll@skia.org Roll Packages from 5d785a0 to 42bb347 (10 revisions) (flutter/flutter#174876) 2025-09-03 chinmaygarde@google.com Fixup formatting of gn files in the old buildroot. (flutter/flutter#174852) 2025-09-03 iinozemtsev@google.com Roll Dart SDK to 3.10.0-162.1.beta (flutter/flutter#174834) 2025-09-03 mdebbar@google.com Mark Linux web_canvaskit_tests_7_last as bringup (flutter/flutter#174878) 2025-09-02 flar@google.com [Impeller] Fix overdraw in DrawRect geometry (flutter/flutter#174735) 2025-09-02 chinmaygarde@google.com Patch .clang-format files to specify C++20. (flutter/flutter#174848) 2025-09-02 mosum@google.com Add data assets (flutter/flutter#174685) 2025-09-02 mohellebiabdessalem@gmail.com refactors `FlutterPlugin.kt` to use one line statement in the `into` bloc (flutter/flutter#174759) 2025-09-02 47866232+chunhtai@users.noreply.github.com Ensures initial semantics state is sent to engine (flutter/flutter#174845) 2025-09-02 43054281+camsim99@users.noreply.github.com [Android] Break up plugin_test integration tests (flutter/flutter#174728) 2025-09-02 34465683+rkishan516@users.noreply.github.com Fix: Assertion failure in RawScrollbarState with dynamic controller assignment (flutter/flutter#173156) 2025-09-02 engine-flutter-autoroll@skia.org Roll Skia from 359f3d7cc7ed to 7c2f502e3304 (1 revision) (flutter/flutter#174844) ...
fix: flutter#171264 should use cell rect bottom to compare with row height instead of using cell rect top. ## 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], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
fix: flutter#171264 should use cell rect bottom to compare with row height instead of using cell rect top. ## 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], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
…r#9962) Roll Flutter from 6b18740d5a23 to 87d5b753196c (88 revisions) flutter/flutter@6b18740...87d5b75 2025-09-05 bkonyi@google.com [ Device Lab ] Add regression testing for flutter/flutter#174952 (flutter/flutter#174956) 2025-09-05 engine-flutter-autoroll@skia.org Roll Skia from 0ca53adfc6cc to 845ec125e94c (2 revisions) (flutter/flutter#174978) 2025-09-05 bruno.leroux@gmail.com [a11y-app] Fix NavigationRail leading and trailing labels (flutter/flutter#174861) 2025-09-05 engine-flutter-autoroll@skia.org Roll Skia from d7e99be07d5d to 0ca53adfc6cc (5 revisions) (flutter/flutter#174972) 2025-09-05 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from izfNA3o_2zL4Cjqmy... to xG_uERsxHvUwFHpF2... (flutter/flutter#174970) 2025-09-04 bruno.leroux@gmail.com Fix IconButton.color overrided by IconButtomTheme (flutter/flutter#174515) 2025-09-04 mdebbar@google.com [web] Reuse chrome instance to run all flutter tests (flutter/flutter#174957) 2025-09-04 pedromassango.developer@gmail.com fix(Semantics): Ensure semantics properties take priority over button's (flutter/flutter#174473) 2025-09-04 15619084+vashworth@users.noreply.github.com Make every LLDB Init error message actionable (flutter/flutter#174726) 2025-09-04 jhy03261997@gmail.com Fix table cell semantics rect alignment issues. (flutter/flutter#174914) 2025-09-04 34465683+rkishan516@users.noreply.github.com Fix: Use route navigator for CupertinoSheetRoute pop (flutter/flutter#173103) 2025-09-04 bkonyi@google.com [ Widget Preview] Add `group` property to `Preview` (flutter/flutter#174849) 2025-09-04 47866232+chunhtai@users.noreply.github.com Allow OverlayPortal.overlayChildLayoutBuilder to choose root Overlay (flutter/flutter#174239) 2025-09-04 engine-flutter-autoroll@skia.org Roll Skia from 7c2f502e3304 to d7e99be07d5d (18 revisions) (flutter/flutter#174936) 2025-09-04 mdebbar@google.com Remove 'terms of use' wording from web_unicode (flutter/flutter#174939) 2025-09-04 bkonyi@google.com [ Tool ] Remove leftover Android x86 deprecation warning constant (flutter/flutter#174941) 2025-09-04 15619084+vashworth@users.noreply.github.com Prevent potential crash when accessing window in FlutterSceneDelegate (flutter/flutter#174873) 2025-09-04 engine-flutter-autoroll@skia.org Roll Packages from 42bb347 to 98580c6 (5 revisions) (flutter/flutter#174943) 2025-09-04 bkonyi@google.com [ Device Lab ] Fix wakefulness check to only match log entries with string values (flutter/flutter#174953) 2025-09-04 bruno.leroux@gmail.com Fix expanded DropdownMenu panel is shorter than text field (flutter/flutter#174443) 2025-09-04 31859944+LongCatIsLooong@users.noreply.github.com Add a `viewController` property to the ios/macOS `FlutterPluginRegistrar` protocol (flutter/flutter#174168) 2025-09-03 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from J3T_wZqL_57mRfWky... to izfNA3o_2zL4Cjqmy... (flutter/flutter#174908) 2025-09-03 47866232+chunhtai@users.noreply.github.com Wires up Android API to set section locale (flutter/flutter#173364) 2025-09-03 chinmaygarde@google.com Delete impeller::SPrintF. (flutter/flutter#174900) 2025-09-03 ahmedsameha1@gmail.com Make sure that a DropdownMenuFormField doesn't crash in 0x0 environment (flutter/flutter#174777) 2025-09-03 mdebbar@google.com Remove unnecessary `presubmit_max_attempts` from .ci.yaml (flutter/flutter#174885) 2025-09-03 mdebbar@google.com Use local canvaskit in `dart_data_asset_test.dart` (flutter/flutter#174891) 2025-09-03 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Mark Linux web_canvaskit_tests_7_last as bringup (#174878)" (flutter/flutter#174897) 2025-09-03 victorsanniay@gmail.com Correct intrinsics calculation for CupertinoTextField with placeholder (flutter/flutter#174889) 2025-09-03 11901536+romaingyh@users.noreply.github.com Considers large title height in CupertinoNavigationBar's preferred size (flutter/flutter#173722) 2025-09-03 victorsanniay@gmail.com [A11y] Add semantics for CupertinoExpansionTile (flutter/flutter#174480) 2025-09-03 sokolovskyi.konstantin@gmail.com Fix LinearProgressIndicator track painting. (flutter/flutter#173108) 2025-09-03 matt.boetger@gmail.com update triage documentation to include team-android (flutter/flutter#174850) 2025-09-03 mdebbar@google.com Update `test_timeout_secs` to match `timeout` for `Linux web_skwasm_tests_*` and `Linux web_canvaskit_tests_*` (flutter/flutter#174881) 2025-09-03 engine-flutter-autoroll@skia.org Roll Packages from 5d785a0 to 42bb347 (10 revisions) (flutter/flutter#174876) 2025-09-03 chinmaygarde@google.com Fixup formatting of gn files in the old buildroot. (flutter/flutter#174852) 2025-09-03 iinozemtsev@google.com Roll Dart SDK to 3.10.0-162.1.beta (flutter/flutter#174834) 2025-09-03 mdebbar@google.com Mark Linux web_canvaskit_tests_7_last as bringup (flutter/flutter#174878) 2025-09-02 flar@google.com [Impeller] Fix overdraw in DrawRect geometry (flutter/flutter#174735) 2025-09-02 chinmaygarde@google.com Patch .clang-format files to specify C++20. (flutter/flutter#174848) 2025-09-02 mosum@google.com Add data assets (flutter/flutter#174685) 2025-09-02 mohellebiabdessalem@gmail.com refactors `FlutterPlugin.kt` to use one line statement in the `into` bloc (flutter/flutter#174759) 2025-09-02 47866232+chunhtai@users.noreply.github.com Ensures initial semantics state is sent to engine (flutter/flutter#174845) 2025-09-02 43054281+camsim99@users.noreply.github.com [Android] Break up plugin_test integration tests (flutter/flutter#174728) 2025-09-02 34465683+rkishan516@users.noreply.github.com Fix: Assertion failure in RawScrollbarState with dynamic controller assignment (flutter/flutter#173156) 2025-09-02 engine-flutter-autoroll@skia.org Roll Skia from 359f3d7cc7ed to 7c2f502e3304 (1 revision) (flutter/flutter#174844) ...
fix: #171264
should use cell rect bottom to compare with row height instead of using cell rect top.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.