-
Notifications
You must be signed in to change notification settings - Fork 72
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.
We may need to update these wdio tests to account for the new prop.
terra-framework/packages/terra-data-grid/tests/wdio/data-grid-spec.js
Lines 283 to 296 in 26f559f
it('clicks the button instead of diving in if it is the only component in the cell', () => { | |
const modal = browser.$('[aria-modal="true"]'); | |
expect(modal.isDisplayed()).toBe(false); | |
browser.keys(['Tab', 'Tab', 'ArrowDown', 'ArrowRight', 'Enter']); | |
expect(modal.isDisplayed()).toBe(true); | |
expect(browser.$('/html/body/div[2]/div[2]/div/div/div/div[4]/div/button').isFocused()).toBe(true); | |
}); | |
it('focuses on a hyperlink if it is the only component in a cell', () => { | |
browser.keys(['Tab', 'Tab', 'ArrowDown', 'ArrowRight', 'ArrowRight', 'ArrowRight']); | |
expect(browser.$('//*[@id="default-terra-data-grid-focusable-cell-table"]/tbody[2]/tr[1]/td[3]/div/a').isFocused()).toBe(true); | |
}); |
/** | ||
* Determines if focus is moved to the interactive element of a cell when a single button or hyperlink element is the only interactive element. | ||
*/ | ||
isAutoFocusEnabled: PropTypes.bool, |
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.
would enableAutofocus
make sense as a simpler name?
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 tried to follow the naming pattern of some of the other props. However, I can make this change if it is the desired update.
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 think the is___
pattern is preferred. Would a name like isAutofocusable
or similar work? (Not sure if that's sufficiently descriptive of the prop's usage though)
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.
If we're keeping to the is__
pattern, then I think both these names are similar enough that either works.
@@ -282,7 +289,7 @@ const DataGrid = forwardRef((props, ref) => { | |||
|
|||
// Set focus to a single header button or hyperlink if they are the only content in cell | |||
const cellButtonOrHyperlink = focusedCell.querySelector('a, button'); | |||
if ((isHeaderRow && !focusedCell.hasAttribute('tabindex')) || cellButtonOrHyperlink) { | |||
if ((isHeaderRow && !focusedCell.hasAttribute('tabindex')) || (isAutoFocusEnabled && cellButtonOrHyperlink)) { |
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.
will action buttons on header cells still be autofocused, regardless of the prop?
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.
The first half of the condition is for the header row and all unit tests pass. I will manually confirm though.
Yes, the button in the row header is still being selected.
I already made this update in the test file to account for the new prop. |
rowHeaderIndex={rowHeaderIndex} | ||
rowHeight="50px" | ||
ariaLabel="Worklist Data Grid" | ||
/> |
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.
It looks like this example is missing isAutoFocusEnabled
prop
Is there an example where the action button autofocus can be tested with UPD: I locally updated an example with actions with |
@cm9361 - I tested 2 examples Worklist Data Grid Autofocusable Cell and Worklist Data Grid Focusable Cell. Keyboard navigation is working as required in both. JAWS announcements are working as required in both. |
Summary
What was changed:
The isAutoFocusEnabled property was introduced to control whether cell with a single focusable element that is a button or hyperlink gets focus automatically during cell navigation.
Why it was changed:
Testing
This change was tested using:
Reviews
In addition to engineering reviews, this PR needs:
Additional Details
This PR resolves:
UXPLATFORM-XXXX
Thank you for contributing to Terra.
@cerner/terra