Skip to content

Conversation

@snowystinger
Copy link
Member

@snowystinger snowystinger commented Jun 9, 2022

Closes

Removes the deprecated way of doing column sizing.
Splits tests out that are concerned with layout, this will speed up Jest a little bit as well as make it easier to navigate to a test of interest. No new tests were added.

This part of the refactor fulfills:

  • Get new TableView behavior passing all tests
  • deletes spooky column
  • makes tests more accurate using modern jest timer mocks
  • removes deprecated table view from code path and deletes it
  • pulls column resizing out of the useTableState hook as a separation of concerns, now other libraries can choose if they include that code

Open questions:
Do we care that this is a breaking change to TableLayout? Nope, it's undocumented and really only used internally
Do we still want a feature flag? we are doing full release

✅ 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:

🧢 Your Project:

@snowystinger snowystinger changed the title Tableview col resizing works with tests Tableview col resizing Jun 9, 2022
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.

Noticed the following issues that didn't exist on the previous build:
https://reactspectrum.blob.core.windows.net/reactspectrum/d736e9bb4c9b1b08cc43b40d535e7a181448b9d7/storybook/index.html?path=/story/tableview--allowsresizing-uncontrolled-static-widths&providerSwitcher-toastPosition=bottom
Resizing with any resize handle but the last one causes the last column to collapse.

similar issue exists in the following story:
https://reactspectrum.blob.core.windows.net/reactspectrum/d736e9bb4c9b1b08cc43b40d535e7a181448b9d7/storybook/index.html?path=/story/tableview--allowsresizing-hiding-columns&providerSwitcher-toastPosition=bottom

  1. Hide "Reach" and "Target OTP"
  2. Grab the right most resize handle and drag it as far to the left as you can
  3. Grab the next resize handle and drag it to the left. Note that it collapses the last column
Comment on lines -394 to +396
// setting the table width will recalculate column widths which we only want to do once the virtualizer is done initializing
if (state.virtualizer.contentSize.height > 0) {
setTableWidth(rect.width);
}
setTableWidth(rect.width);
Copy link
Member

Choose a reason for hiding this comment

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

Was this part of the spooky column code? Or an optimization?

Copy link
Member Author

@snowystinger snowystinger Jun 14, 2022

Choose a reason for hiding this comment

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

This was that bit of code that you and I looked at together when we were fixing the tests. I don't recall the exact reason, but we didn't need to wait for initialization. It's not related to the spooky column though. I'll try to find more of the reason for the change.

LFDanLu
LFDanLu previously approved these changes Jun 15, 2022
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

reidbarber
reidbarber previously approved these changes Jun 16, 2022
devongovett
devongovett previously approved these changes Jun 17, 2022
Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

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

Had a couple questions, but approving to unblock future work.

acc.push(options[key]);
}
return acc;
}, []);
Copy link
Member

Choose a reason for hiding this comment

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

Why is this written like this rather than just coding it as an array in the first place?

Copy link
Member Author

Choose a reason for hiding this comment

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

we had some issues with null children in Menu's at one point, I might've been defensively coding against that memory
I'll update in my next PR

manyItems.push({id: i, foo: 'Foo ' + i, bar: 'Bar ' + i, baz: 'Baz ' + i});
}

describe('TableViewSizing', function () {
Copy link
Member

Choose a reason for hiding this comment

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

Why moved?

Copy link
Member Author

Choose a reason for hiding this comment

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

Effort to make test file smaller, it was getting slow for Jest to run
It may be that Jest sharding takes care of this, however, it was also a bit unwieldy in terms of human readability, scrolling that much just causes me to want to die, and this new file is where I'll be adding a bunch of tests around resize behavior in my next PR

# Conflicts: #	packages/@react-spectrum/table/test/Table.test.js
@snowystinger snowystinger dismissed stale reviews from devongovett, reidbarber, and LFDanLu via e9e1e6c June 22, 2022 18:31
@snowystinger snowystinger merged commit bf297bc into main Jun 22, 2022
@snowystinger snowystinger deleted the tableview-col-resizing-works-with-tests branch June 22, 2022 18:49
@snowystinger snowystinger mentioned this pull request Jul 1, 2022
61 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants