-
Notifications
You must be signed in to change notification settings - Fork 42
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
Excluded sub-component id
in newState
when handling selection in Table
#2317
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Table
Table
onSelect
in Table
r100-stack
reviewed
Oct 28, 2024
packages/itwinui-react/src/core/Table/actionHandlers/selectHandler.ts
Outdated
Show resolved
Hide resolved
1 task
mayank99
approved these changes
Oct 28, 2024
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.
LGTM.
Would be worth mentioning in the PR description that you looked through the react-table
source code to verify that no other places use sub-rows (iirc filters do but it was ok?)
onSelect
in Table
id
from newState
when handling selection in Table
id
from newState
when handling selection in Table
id
in newState
when handling selection in Table
r100-stack
reviewed
Oct 29, 2024
packages/itwinui-react/src/core/Table/actionHandlers/selectHandler.ts
Outdated
Show resolved
Hide resolved
packages/itwinui-react/src/core/Table/actionHandlers/selectHandler.ts
Outdated
Show resolved
Hide resolved
mayank99
reviewed
Oct 30, 2024
mayank99
approved these changes
Oct 30, 2024
r100-stack
approved these changes
Oct 30, 2024
Merged
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
As the only difference between these two types of data is the
Symbol
key to mark whether the row is a sub-component or not,onSelect
turned out to return duplicate data. This PR excluded the data of sub-component from the returned selected data from theonSelect
function as it was the same as that of the main row, as reported in issue.I have gone through
react-table
v7 source code and observed that other functionalities should not affect by sub-components being sub-rows. Even though sorting and filtering still loop through sub-rows, these functionalities only utilize the data for their logic but not return it as their resulting data. Additionally, the sub-components' data should be the same that of the main rows, which does not affect the logic of these functionalities.Testing
Added unit test for row selecting when
subComponent
is present.Docs
Added changeset.
After-PR TODO:
initialSubRows
instead ofsubRows
(Excluded sub-componentid
innewState
when handling selection inTable
#2317 (comment))