fluentui icon indicating copy to clipboard operation
fluentui copied to clipboard

Column count is read twice by narrator(first time with wrong column index) when the column rendered is given role="gridcell" from consumer end

Open mdmdakbar opened this issue 8 years ago • 4 comments

Product affected: VSTS

Scenario: I am consuming DetailsList and in onRenderItemColumn, I am returning a div element with role="gridcell". onRenderItemColumn={() => {return <div data-is-focusable="true" aria-selected="true" role="gridcell">Akbar</div>}}

Suppose list has few rows and 4 columns including checkbox.

Issue: When we go to some row and select 2nd column then narrator reads "Column header abc ... column 5 of 4 ... column 2 of 4".

The first announcement is wrong. It is reading (number of columns + 1) columns unnecessarily.

Expected behavior: It should read "Column header abc ... column 2 of 4" only.

Codepen repro: https://codepen.io/mdmdakbar/pen/WKYNOK (with latest version)

I tried using Grid structure and creating the same scenario there but narrator reads correctly there. https://codepen.io/mdmdakbar/pen/JBePaV

Reason for giving role here is we want to give aria-selected to div element but it will work only if some role is provided to it

Please find attached file for more info. detailslist1

This issue can be easily repro in office fabric components DetailsList example.

Choose any example and modify the content of the column with <div role="gridcell" data-is-focusable="true">itemContent</div> and then try to focus on it via keyboard. You will hit the issue there as well.

Please let me know if you need any further details.

mdmdakbar avatar Aug 08 '18 15:08 mdmdakbar

The codepen has bad code. There should not be a gridcell inside a gridcell. Unless otherwise explained, this is user error. You can't just say

Reason for giving role here is we want to give aria-selected to div element but it will work only if some role is provided to it

Yes, aria-selected can only be applied on an element that has an appropriate role, but why are you nesting your <div>s in the first place?

metapzl avatar Aug 08 '18 16:08 metapzl

Scenario: I am using details list and we are custom rendering every cell and each of my cell is focusable.

We have a cell which has a simple text wrapped in div and is focusable and as soon as we click on that text it changes to an editable input. And onBlur again, it becomes a text wrapped in div element.

Now, as the focus goes to div element, narrator announces it as group which is wrong since we know it is a grid cell and not group. image

Element which is focusable, editable and selectable should have a proper role and group doesn't seem right there.

To fix this issue, we gave role="gridcell" to that div. I do not see any other reasonable role which can be applied here other than gridcell.

And since element is focusable, we provided aria-selected also.

Is there any other way to overcome this scenario or if details list provide some way so that it doesnot announce group and handles aria-selected when element is focusable. OR why not details list allowing us to render the entire cell with role="grid cell"? Why they render each column with role="gridcell" and then in child rendering our column cell?

I agree nested gridcell is a bad example. but why are you nesting your <div>s in the first place What do you mean by in the first place ?

mdmdakbar avatar Aug 09 '18 06:08 mdmdakbar

I am using details list and we are custom rendering every cell and each of my cell is focusable.

I'm gonna ask you to back up a bit because what I'm understanding right now is that you're using the wrong tool to solve your problem and trying to hack the tool to hide that fact...

Can you give more details about what you're trying to do, instead of what you're currently doing? If you need, ping me on Teams.

I hesitate to say that what you actually want to pass in is onRenderRow and not onRenderItemColumn if you want to not nest your <div>s because I'm a little worried what you might do with that :) Are you actually looking to build a table structure with full access to every single cell, etc.? DetailsList is meant for a List (at least semantically) and I'm not confident it should be used.

metapzl avatar Aug 09 '18 19:08 metapzl

Agreed, we are over costumizing the component. Probably, we should have our own component or atleast we should have rendered the entire row from our side via onRenderRow.

Thanks for your prompt responses. Closing the bug.

mdmdakbar avatar Aug 10 '18 13:08 mdmdakbar