Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Table): Adding table navigation #2147

Merged
merged 31 commits into from
Dec 12, 2019
Merged

Conversation

kolaps33
Copy link
Collaborator

@kolaps33 kolaps33 commented Dec 4, 2019

Adding table navigation like:

  • row by row navigation
  • navigate inside the row use right arrow key
  • in the row, then right and left arrow keys navigate between the cells

What should works:

  • when cell has more actionable elements, then:
    • "Enter" key goes inside the cell
    • "Escape" key goes outside the cell
    • navigation between actionable elements inside cell is up/down and left/right arrows
  • when cell has one actionable element, then focus goes directly to the actionable element
  • space/enter invoke onclick on row
  • space/enter invoke onclick on actionable element(more option button)
  • click invoke onclick on whole row
  • click invoke onclick on actionable element(more option button)
Microsoft Reviewers: Open in CodeFlow

@kolaps33 kolaps33 changed the title Adding table navigation feat(Table): Adding table navigation Dec 4, 2019
moreOptionButton,
],
onClick: () => handleRowClick(1),
'aria-label': 'custom text',
Copy link
Contributor

Choose a reason for hiding this comment

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

what does custom text mean? I think it would be better to use meaningful labels in the examples

@jurokapsiar
Copy link
Contributor

can you please add handlesAccessibility tests to the unit tests of the table, row and cell?

@@ -0,0 +1,22 @@
import { Accessibility } from '../../types'
import { IS_FOCUSABLE_ATTRIBUTE } from '../../attributes'
// import * as keyboardKey from 'keyboard-key'
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove these comments

import * as keyboardKey from 'keyboard-key'
import gridHeaderCellBehavior from './gridHeaderCellBehavior'

// add key actions unit tests
Copy link
Collaborator

Choose a reason for hiding this comment

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

and these

// add key actions unit tests

/**
* @description
Copy link
Collaborator

Choose a reason for hiding this comment

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

if you don't add anything to description just remove them, otherwise add description about the behavior.

@@ -609,6 +609,21 @@ definitions.push({
},
})

// Triggers 'unsetRowTabbable' action using SHIFT + TAB key on 'root'.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should abstract this, so we can include stuff like Triggers 'openAndFocusFirst' action with 'altKey'+'ArrowDown' on 'root' slot.

Maybe we can also add the part with based on the prop $propname so we ca include stuff like:

          ...(!props.open && {
            openAndFocusFirst: {
              keyCombinations: [{ keyCode: keyboardKey.ArrowDown, altKey: true }],
            },
          }),

@@ -513,16 +513,16 @@ export default class FocusZone extends React.Component<FocusZoneProps> implement

const doc = getDocument(this._root.current)

if (this.props.onKeyDown) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can probably use lodash invoke here: _.invoke(this.props, 'onKeyDown', ev)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

as this is FocusZone code I rather don't want to change the code...
Even this change we are asking if focusZone people agree with the change.

Choose desired accessibility behavior for grid cell depending on the use case.(Check the{' '}
{link('Behaviors', '/components/table/accessibility')} section).
</Text>,
'Provide label to the Table component using `aria-label` or `aria-labelledby` prop.',
Copy link
Contributor

Choose a reason for hiding this comment

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

pls add: If no label is provided, the whole header will be read by the screen reader when the user navigates to the table

{link('Behaviors', '/components/table/accessibility')} section).
</Text>,
'Provide label to the Table component using `aria-label` or `aria-labelledby` prop.',
'Provide label to the Row component using `aria-label` or `aria-labelledby` prop. If not, then each cell of the row is narrated by screen reader.',
Copy link
Contributor

Choose a reason for hiding this comment

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

pls change to Consider providing label to the TableRow component using aria-label or aria-labelledby prop. When not provided, the whole row (all cells) will ne narrated by the screen reader when the user navigates to the row.

'Provide label to the Table component using `aria-label` or `aria-labelledby` prop.',
'Provide label to the Row component using `aria-label` or `aria-labelledby` prop. If not, then each cell of the row is narrated by screen reader.',
'Provide label to the table header column, if cell has no content.',
'Stop event propagation, when you will add actionable element into the grid cell.',
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use actionable element or component in the cell, stop propagation of the click event if you do not want the interacion with the element to perform row click action.

]

const dontList = [
"Don't set onClick action on row, which will be not available in the cell of grid, as well. With screen reader navigation user can navigate only cell by cell.",
Copy link
Contributor

Choose a reason for hiding this comment

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

If you use onClick on the row, make also one (preferably the first) cell actionable and add onClick handler with the same action to it. Screen readers do not navigate to rows, so actions need to be available on cells as well.


function tagButton(tagName: string) {
return (
<Provider
Copy link
Contributor

Choose a reason for hiding this comment

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

make sure to have only one provider in the example, not for each button

@kolaps33 kolaps33 merged commit f82c8a0 into master Dec 12, 2019
@kolaps33 kolaps33 deleted the mituron/table-navigation branch December 12, 2019 15:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants