Skip to content

TableView Column resizing #2883

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

Merged
merged 137 commits into from
Mar 18, 2022
Merged

TableView Column resizing #2883

merged 137 commits into from
Mar 18, 2022

Conversation

dnorth
Copy link
Contributor

@dnorth dnorth commented Feb 23, 2022

Closes #2555

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

  • storybook tests with 'allowsResizing' prop in TableView
  • npm run test Table.test.js

TODOs as followup potentially

  • Move resizers up to be siblings of the rows such that their hit area can cover the columns and the focus ring is visible all the way around
  • Get rid of the timeout to move focus from the menutrigger to the resizer, right now it's dependent on the menutrigger close timeout of ~350ms when the focus is restored to the trigger element

🧢 Your Project:

Adobe Analytics (Analysis Workspace)

Marshall Peterson and others added 30 commits January 4, 2022 15:49
Also refactor the way we recalculate columns to only re-calculate dynamic columns for performance and predictability for the onResize. Also refactor useColumnResizeWidthState out of useTableState.
Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

You shouldn't need a .rtl class, that should be taken care of by logical properties

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Initial review, doing a deep dive of the state, layout, and virtualizer changes next

Comment on lines +51 to +52
// Disabled for allowsResizing because if resizing is allowed, a menu trigger is added to the column header.
isDisabled: !allowsSorting || isSelectionCellDisabled || allowsResizing,
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps a minor point:
Is adding a menu trigger to the column header when the column supports resizing an interaction pattern we'll be recommending for a non-Spectrum tables as well? If not, then I don't know if we wanna disable the press to sort interactions here, perhaps the pressProps from this hook should be overridden in the TableView instead.

Just thinking about a case where someone using our table hooks implements column resizing in a such a way that pressing the column headers should perform the sort action still and resizing via keyboard is handled in a different way (keyboard shortcut maybe? I'll need to dig to see if any other tables support resizing columns via keyboard).

role="separator"
aria-orientation="vertical"
aria-label="Resize column"
aria-labelledby={item.key}
Copy link
Member

Choose a reason for hiding this comment

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

This won't actually point to a id that exists in the DOM. Maybe you could use getColumnHeaderId?

As an aside I noticed that the column headers also have lost their "columnheader" role in favor of the "button" role provided by MenuTrigger, note to self to double check that the rest of the attributes are still valid (it seems ok so far?)

Comment on lines +1201 to +1205
.add(
'allowsResizing, uncontrolled, sortable columns',
() => <AsyncLoadingExample isResizable />,
{chromatic: {disable: true}}
)
Copy link
Member

Choose a reason for hiding this comment

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

I noticed considerable slowdown when sorting a table with resizable columns vs non-resizable columns, even when dealing with a static collection. I'll need to dig into exactly why this is, but noting it for 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.

After our virtualizer changes we noticed that the speed of sorting increased significantly. We're hoping those changes fixed the problem but this is something we also care about deeply and so it's the first thing we're planning on testing once we get it in our codebase.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, I'll give it a quick once over but def not blocker for merge

@@ -10,6 +10,8 @@
* governing permissions and limitations under the License.
*/

export * from './useTableColumnResizeState';
export * from './utils';
Copy link
Member

Choose a reason for hiding this comment

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

Should these utils be exported? Are we expecting them to be used by other users? From what I can see they are just used by useTableColumnResizeState and the stately tests so perhaps we shouldn't export them

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 use getContentWidth in the useTableColumnResizeState.test.ts file like you said, so do you recommend we remove this export and then import in our test file like so?

  import {getContentWidth} from '../src/utils';
  import {renderHook} from '@testing-library/react-hooks';
  import {useTableColumnResizeState} from '../';

Copy link
Member

Choose a reason for hiding this comment

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

Right, no need to export anything that users/other packages won't use. We can always export them in the future if the need arises but for now we should exclude it IMO

snowystinger
snowystinger previously approved these changes Mar 18, 2022
Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

Ran chromatic as well

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

LGTM, feel free to address my previous comments in a followup. Things seem to performing much better now (especially sorting), thanks for all the great work!

@snowystinger snowystinger merged commit b778c8d into adobe:main Mar 18, 2022
@dannify dannify changed the title Column resizing TableView Column resizing Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TableView column resizing
6 participants