Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Terra Table Resize Fixes #1885

Closed
wants to merge 12 commits into from
Closed

Terra Table Resize Fixes #1885

wants to merge 12 commits into from

Conversation

kenk2
Copy link
Contributor

@kenk2 kenk2 commented Nov 9, 2023

Summary

What was changed:
Added tests for column resizing in table. Addressed an issue of column resizing not announcing aria values when in non-grid contexts. Also added examples for showing resizable columns in tables.

Why it was changed:
To fix some potential aria issues and to test the behavior of resizing columns for tables.

Testing

This change was tested using:

  • WDIO
  • Jest
  • Visual testing (please attach a screenshot or recording)
  • Other (please describe below)
  • No tests are needed

Reviews

In addition to engineering reviews, this PR needs:

  • UX review
  • Accessibility review
  • Functional review

Additional Details

This PR resolves:

UXPLATFORM-9864


Thank you for contributing to Terra.
@cerner/terra

@kenk2 kenk2 self-assigned this Nov 9, 2023
@kenk2 kenk2 marked this pull request as ready for review November 9, 2023 21:07
@@ -138,6 +138,11 @@ const ColumnResizeHandle = (props) => {
resizeHandleRef.current.style.height = `${height}px`;
};

const handleFocus = () => {
setIsActive(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need add this change now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were not accounting for other ways that the resize handle could be approached. We were only accounting for the datagrid approach (arrows). This logic accounts for other ways that resize handles are reached in components.

@@ -105,7 +105,7 @@ describe('ColumnResizeHandle', () => {
it('sets the appropriate prop values on space keydown', () => {
const wrapper = mountWithIntl(
<ColumnContext.Provider value={{ setColumnHeaderAriaLiveMessage: jest.fn() }}>
<ColumnResizeHandle />
<ColumnResizeHandle setIsActive={jest.fn()} />
Copy link
Contributor

Choose a reason for hiding this comment

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

We are adding a new prop to pass a function, but it does not seem like we are testing to ensure it was called. What are we attempting to validate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this change because we were previously only setting this on keyboard navigation, but this should always be active regardless of how it was focused (besides mouse events). I have added comments and a mock to clarify the purpose of adding this parameter.

@cm9361
Copy link
Contributor

cm9361 commented Nov 9, 2023

You don't have a JIRA in your PR template.

Copy link
Contributor

Choose a reason for hiding this comment

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

There have been recent changes in main, so make sure that the CHANGELOG entries are in the right section.

@kenk2
Copy link
Contributor Author

kenk2 commented Nov 21, 2023

@mjpalazzo To validate accessibility, I set up a new example with Resizeable columns in Table: https://engineering.cerner.com/terra-framework/pull/1885/components/cerner-terra-framework-docs/table/examples/resizable-columns

It should announce aria values when the columns are reached via tab, but not with mouse events.

We should also test the resize handle behavior in WorklistDataGrid as well. It should not take on aria values when the resize is focused with the mouse, but should take on aria values when reached by the arrow keys.

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we already have example for column resizing? We should not need a new example to show this functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Turns out we did not have them previously. I added them because we did not have an example for a core feature that should have an example.

Copy link
Contributor

Choose a reason for hiding this comment

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

We already have tests for column resizing. We should not need a new test file.

@@ -15,6 +15,11 @@ afterAll(() => {
});

describe('ColumnResizeHandle', () => {
const mockSetIsActive = jest.fn();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this not just defined in the tests that require it? This does not seem like something we should have to validate every test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since we're now calling setIsActive on every non-mouse focus event, we are required to set it in the test suites. I figured we ought to validate that the function is set/not set when appropriate on all the tests but if we feel strongly about it, then we can discuss this further.

@@ -108,6 +108,8 @@ const ColumnResizeHandle = (props) => {

// Ref variable for native resize handle element
const resizeHandleRef = useRef();
// Ref variable to prevent active state on mouse drag
const handleFocus = useRef(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we use the isActive prop? It seems like that would work without this extra logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We do a similar implementation in DataGrid where we use the ref to control the onFocus callback. Since mouseDown also calls focus, we have to set this in order to prevent focus from being called as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

In that scenario, we don't have the isActive prop that we can leverage. Also, focus is being given to the DataGrid externally. Why is the isActive prop not sufficient would be my question.

@mjpalazzo
Copy link
Contributor

mjpalazzo commented Nov 21, 2023

@kenk2 - I tried validating the resizable columns example with JAWS, but the keyboard navigation was not working for me. I could Tab to the column resizing tool. JAWS announced "Press Enter to use. Column header, Patient , column 1 row" I pressed Enter and I no longer had focus on the resizing tool. Focus seemed to go to the frame around the table. Note also that in the example the Illness Severity and Visit column headers are buttons and can receive focus, but the other column headers are not interactive.

@kenk2 kenk2 closed this Nov 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants