-
Notifications
You must be signed in to change notification settings - Fork 29.8k
[framework]Add semantics role to table rows. #163337
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
Conversation
|
hmmm looks like i should not simply remove |
Oof, that's a tricky problem. What's the typical value of |
cdd51ee to
f2fbc6c
Compare
f2fbc6c to
3ecbeba
Compare
|
@chunhtai I want to merge this framework changes PR first and the "removing intermediate container layers in web engine" will be a separate effort in another PR. |
9494077 to
50fcfe9
Compare
|
|
||
| final SemanticsConfiguration configuration = | ||
| SemanticsConfiguration() | ||
| ..indexInParent = i |
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.
is this going to be used by the row index? if so, does the cell also uses this to set the col index? we should unify the way to set these indices in web.
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 indexInParent for cells
| children: const <TableRow>[ | ||
| TableRow(children: <Widget>[Text('AAAAAA'), Text('B'), Text('C')]), | ||
| ], | ||
| TableCell( |
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.
Is this needed for semantics check? do we need to worry about this being a breaking change?
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.
yes because the test case here before is a very corner case putting a table inside a tablerow child, so it became table-> row-> table and it failed the new a11y check, i think cases like this are very rare and they are just made up for tests
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.
no, this is a case i replicate from internal code.
Should the tableRow assign the TableCell to its children internally?
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.
Should the tableRow assign the TableCell to its children internally?
I'm already doing that in assembleSemanticsNode, i assign the role to its children if the children have no roles.
but if the children already have roles(in this case, it's table), do we want to override that role? or do we want to insert a semantics node with a cell role between them?
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.
I'm already doing that in assembleSemanticsNode
Assigning child property in assembleSemanticsNode seems a bit hacky. We should do it through the TableCell widget if possible.
do we want to insert a semantics node with a cell role between them
This would be ideal, but doing it in widget layer means the Table here needs to be wrap with a semantics container. I think for now, let's just override it without creating a container. As you said this may be a rare case, we can fix it if it really is an issue
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.
also looks like this pr will make the table to be a container so there may not be overriding role issue in this particular case
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.
Assigning child property in assembleSemanticsNode seems a bit hacky. We should do it through the TableCell widget if possible.
We can't because we don't enforce user to use TableCell widget in table, TableRow can take any widgets as its children. User can just assign a Text widget to TableRow's children. That's why I assign the role here.
I think for now, let's just override it without creating a container.
SGTM,
there may not be overriding role issue in this particular case
in This particular case, the test case was table-> row-> table- > row-> cell, If I don't override the second table role , it will fail the check because row's children shouldn't be a table, if i override the second table role to be a cell, it will become table-> row-> cell- > row-> cell, it will fail the check because row's parent shouldn't be a cell. So I see the only way to fix this test case is to insert a cell and it will become table-> row-> cell -> table- > row-> cell,
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 would be ideal
Updated this PR to insert a semantics node with a cell role between them.
|
I just realized I had some misunderstanding about semanticsNode rect before. I thought the tree dump rect is actual semanticsnode.rect, but it's actually semanticsnode.rect with semanticsnode.transform. Instead of only setting row's and cell's Updated PR. |
| children: const <TableRow>[ | ||
| TableRow(children: <Widget>[Text('AAAAAA'), Text('B'), Text('C')]), | ||
| ], | ||
| TableCell( |
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.
I'm already doing that in assembleSemanticsNode
Assigning child property in assembleSemanticsNode seems a bit hacky. We should do it through the TableCell widget if possible.
do we want to insert a semantics node with a cell role between them
This would be ideal, but doing it in widget layer means the Table here needs to be wrap with a semantics container. I think for now, let's just override it without creating a container. As you said this may be a rare case, we can fix it if it really is an issue
| /// {@endtemplate} | ||
| SemanticsRole get role => _role; | ||
| SemanticsRole _role = _kEmptyConfig.role; | ||
| set role(SemanticsRole value) { |
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.
we should avoid this
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.
I want to assign the role cell to the child in assembleSemanticsNode.
And i want to only change its role. So i think this is needed.
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 is removed after offline discussion.
we won't directly change semantics node's role, just wrap them with a new semantics node with a cell role.
| children: const <TableRow>[ | ||
| TableRow(children: <Widget>[Text('AAAAAA'), Text('B'), Text('C')]), | ||
| ], | ||
| TableCell( |
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.
also looks like this pr will make the table to be a container so there may not be overriding role issue in this particular case
I mean we wrap it internally in either Table widget or TableRow widget |
looking at the code, we shouldn't add semanticsRole.cell in TableCell. It should added internally in Table or TableRow, this also avoid forcing people to use TableCell to have the correct semantics |
If you mean like to wrap TableRow's every children with Semantics( role: cell: child: child), I tried that and it didn't work out because TableCell is a ParentDataWidget so it assumes its parent is a Table, insert a Semantics widget between TableCell and Table will crash it. So I chose to assign the semantics role to cells in assembleSemanticsNode although it looks a bit hack 😅 maybe there is a better way to do it ?
make sense, I will remove that. |
**1. framework side:**
This PR Create semantics node for rows in table's
`assembleSemanticsNode` function.
**2. web side:**
I tested on my mac, and i need to remove the
`<flt-semantics-container>` between table and row, row and cell to
traverse inside table, removing those transfom intermediate containers
on web will be a bit of hassle and will be in another separate PR.
For example this code can only announce table but can’t get into cells.
```
<flt-semantics id="flt-semantic-node-4" role="table" style="position: absolute; overflow: visible; width: 751px; height: 56px; transform-origin: 0px 0px 0px; transform: matrix(1, 0, 0, 1, 0, 56); pointer-events: none; z-index: 1;">
<flt-semantics-container style="position: absolute; pointer-events: none; top: 0px; left: 0px;">
<flt-semantics id="flt-semantic-node-6" role="row" style="position: absolute; overflow: visible; width: 751px; height: 56px; top: 0px; left: 0px; pointer-events: none;">
<flt-semantics-container style="position: absolute; pointer-events: none; top: 0px; left: 0px;">
<flt-semantics id="flt-semantic-node-5" role="columnheader" aria-label="Name" style="position: absolute; overflow: visible; width: 751px; height: 56px; top: 0px; left: 0px; pointer-events: all;"></flt-semantics>
</flt-semantics-container>
</flt-semantics>
</flt-semantics-container>
</flt-semantics>
```
If I removed the in between `</flt-semantics-container>`, the code come
```
<flt-semantics id="flt-semantic-node-4" role="table" style="position: absolute; overflow: visible; width: 751px; height: 56px; transform-origin: 0px 0px 0px; transform: matrix(1, 0, 0, 1, 0, 56); pointer-events: none; z-index: 1;">
<flt-semantics id="flt-semantic-node-6" role="row" style="position: absolute; overflow: visible; width: 751px; height: 56px; top: 0px; left: 0px; pointer-events: none;">
<flt-semantics id="flt-semantic-node-5" role="columnheader" aria-label="Name" style="position: absolute; overflow: visible; width: 751px; height: 56px; top: 0px; left: 0px; pointer-events: all;"></flt-semantics>
</flt-semantics>
</flt-semantics>
```
And I can get into table cells.
**3. Other aria-attributes:**
[aria-colcount](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-colcount) ,[aria-rowcount](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-rowcount)
[aria-colindex](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-colindex)
[aria-rowindex](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-rowindex)
* theres attributes are only needed if some rows and columns are hidden
in the Dom tree. havn't added them yet
aria-rowspan , aria-colspan :
*we currently don't support row span and col span in our widgets.
related issue: flutter#21594
related: flutter#162339
issue: flutter#45205
## 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].
<!-- 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
1. framework side:
This PR Create semantics node for rows in table's
assembleSemanticsNodefunction.2. web side:
I tested on my mac, and i need to remove the
<flt-semantics-container>between table and row, row and cell to traverse inside table, removing those transfom intermediate containers on web will be a bit of hassle and will be in another separate PR.For example this code can only announce table but can’t get into cells.
If I removed the in between
</flt-semantics-container>, the code comeAnd I can get into table cells.
3. Other aria-attributes:
aria-colcount ,aria-rowcount aria-colindex aria-rowindex
aria-rowspan , aria-colspan :
*we currently don't support row span and col span in our widgets. related issue: #21594
related: #162339
issue: #45205
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.