-
Notifications
You must be signed in to change notification settings - Fork 2
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
NEO-2115 // update Table row selection #444
Conversation
WalkthroughThe changes introduce new logic for managing the selection of visible rows in a table, update translations for table headers, and adjust tests for row selection actions. Specific enhancements include new state variables and functions for handling row visibility and selection, expanded translations, and refined test setups for better clarity. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TableHeader
participant Table
User->>TableHeader: Select all rows on page
TableHeader->>Table: Get current page rows
Table->>TableHeader: Return visible page rows
TableHeader->>Table: Toggle selection for visible rows
Table-->>User: Rows on page selected
User->>TableHeader: Clear all visible rows
TableHeader->>Table: Get current page rows
Table->>TableHeader: Return visible page rows
TableHeader->>Table: Deselect visible rows
Table-->>User: Rows on page deselected
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
✅ Deploy Preview for neo-react-library-storybook ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (11)
- src/components/Menu/Menu.stories.tsx (3 hunks)
- src/components/Menu/Menu.tsx (1 hunks)
- src/components/Menu/MenuItemButton/MenuItemButton.tsx (1 hunks)
- src/components/Menu/MenuItemButton/index.ts (1 hunks)
- src/components/Menu/Menu_shim.css (1 hunks)
- src/components/Menu/index.ts (1 hunks)
- src/components/Table/Table.test.jsx (2 hunks)
- src/components/Table/TableComponents/TableHeader.tsx (4 hunks)
- src/components/Table/Table_shim.css (1 hunks)
- src/components/Table/helpers/default-data.ts (1 hunks)
- src/components/Table/types/TranslationTypes.ts (1 hunks)
Files skipped from review due to trivial changes (5)
- src/components/Menu/Menu.tsx
- src/components/Menu/MenuItemButton/MenuItemButton.tsx
- src/components/Menu/MenuItemButton/index.ts
- src/components/Menu/Menu_shim.css
- src/components/Menu/index.ts
Additional comments not posted (19)
src/components/Table/helpers/default-data.ts (1)
23-26
: Translation strings added correctly.The new translation strings
clearSelection
,clearAllVisibleItems
, andselectAllVisibleItems
are correctly added and follow the existing structure.src/components/Table/types/TranslationTypes.ts (1)
35-38
: New properties added correctly.The new properties
clearSelection
,clearAllVisibleItems
, andselectAllVisibleItems
are correctly added to theITableHeaderTranslations
interface and follow the existing structure.src/components/Table/Table_shim.css (5)
2-7
: Button styles applied correctly.The styles for buttons include color, display, font-weight, padding, and margin adjustments. These changes are correctly applied and enhance the button appearance.
11-13
: Media queries applied correctly.The media queries for light and dark color schemes correctly adjust the button color based on the user's preference.
Also applies to: 17-21
39-39
: Table cell border style applied correctly.The border style for table cells is correctly applied, ensuring a consistent appearance.
43-45
: Pagination styles applied correctly.The styles for pagination include display, flex-direction, height, and alignment adjustments. These changes are correctly applied and enhance the pagination layout.
Also applies to: 47-51
54-82
: Checkbox column styles applied correctly.The styles for the checkbox column include padding, width, hover effects, and dropdown menu adjustments. These changes are correctly applied and enhance the checkbox column appearance.
src/components/Table/TableComponents/TableHeader.tsx (7)
5-5
: New import added correctly.The
MenuItemButton
import is correctly added to support the new functionality.
35-39
: New destructured properties added correctly.The
page
andtoggleRowSelected
properties are correctly added to the destructured properties.
44-54
: Logic for visible rows added correctly.The logic for
visibleRows
,allVisibleRowsAreSelected
, andallVisibleRowsDeselected
is correctly added and ensures proper handling of visible rows.
56-62
: Function for selecting visible rows added correctly.The
selectVisibleRows
function is correctly added and ensures proper selection of visible rows.
73-78
: Checkbox checked value logic added correctly.The logic for determining the checkbox checked value is correctly added and ensures proper handling of the checkbox state.
94-108
: Function for toggling all visible rows added correctly.The
toggleAllVisibleRows
function is correctly added and ensures proper toggling of all visible rows.
114-159
: Checkbox and menu for selecting rows added correctly.The checkbox and menu for selecting rows are correctly added and ensure proper handling of row selection.
src/components/Menu/Menu.stories.tsx (2)
7-7
: Import statement forMenuItemButton
is correctly added.The import statement is correctly added to include the new
MenuItemButton
component.
253-254
: PropsdefaultIsOpen
andcloseOnBlur
are correctly added toMenu
.The new props
defaultIsOpen
andcloseOnBlur
are correctly added and used.src/components/Table/Table.test.jsx (3)
252-252
: SimplifieddefaultSelectedRowIds
prop.The
defaultSelectedRowIds
prop is simplified to include only one ID, making the test setup more straightforward.
317-325
: Updated test setup for deleting rows.The test setup now uses
EditableData
and includes clearer checkbox label references, improving clarity and functionality.
329-329
: Updated checkbox label reference for better readability.The checkbox label reference is updated to use a variable, enhancing readability and maintainability.
This comment was marked as outdated.
This comment was marked as outdated.
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 Table update looks great to me despite of all the naming suggestions. However, I do not see that we need a MenuItemButton component as MenuItem has onClick callback already.
toggleAllRowsSelected, | ||
toggleSortBy, | ||
} = instance; | ||
|
||
const [visibleRows, allVisibleRowsAreSelected, allVisibleRowsDeselected] = |
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.
"visible" and "shown" are not accurate to me. If the page is not selected, all rows in that page are not visible/shown to the user.
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.
Excellent call! As they say, naming is the hardest problem in software, and your recommendations are a significant improvement; thanks for being thorough! I have made the updates that you recommended.
toggleAllRowsSelected, | ||
toggleSortBy, | ||
} = instance; | ||
|
||
const [visibleRows, allVisibleRowsAreSelected, allVisibleRowsDeselected] = | ||
useMemo(() => { | ||
const shownRows = page.map((row) => row.original); |
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.
shownRows => pageRows
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.
updated
const [visibleRows, allVisibleRowsAreSelected, allVisibleRowsDeselected] = | ||
useMemo(() => { | ||
const shownRows = page.map((row) => row.original); | ||
const visibleRowsSelected = |
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.
allRowsSelected or allPageRowsSelected
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.
updated
const shownRows = page.map((row) => row.original); | ||
const visibleRowsSelected = | ||
shownRows.length && shownRows.every((row) => selectedRowIds[row.id]); | ||
const visibleRowsNotSelected = shownRows.every( |
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.
allRowsNoteSlected or noRowsSelected
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.
updated
return [shownRows, visibleRowsSelected, visibleRowsNotSelected]; | ||
}, [page, selectedRowIds]); | ||
|
||
const selectVisibleRows = useCallback( |
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.
selectPageRows
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.
updated
}, [page, selectedRowIds]); | ||
|
||
const selectVisibleRows = useCallback( | ||
(set: boolean) => { |
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.
selected: bolean
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.
updated
@@ -69,19 +91,73 @@ export const TableHeader = <T extends Record<string, any>>({ | |||
checkboxCheckedValue, | |||
rowsById, | |||
]); | |||
const toggleAllVisibleRows = useCallback(() => { |
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.
togglePageRows
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.
updated
Have to retract the approval as I forgot the MenuItemButton keyboard problem.
Need to do some refactoring, closing for now and will re-open. |
@Justin-Avaya, this is all out of scope for this PR as my changes did not cause this. However, this many inconsistencies is particularly worrying and I've thus made a jira issue to resolve these. I'll bring this up with the team in standup tomorrow so we can schedule it. |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/components/Menu/Menu.stories.tsx (1 hunks)
- src/components/Table/TableComponents/TableHeader.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (2)
- src/components/Menu/Menu.stories.tsx
- src/components/Table/TableComponents/TableHeader.tsx
@yangAtSpoken good catch, I'll talk to Matt about it as he is the one who defined these use-cases |
Can not move focus to the last menu item with keyboard. @yangAtSpoken can't reproduce. I must have broken it and then fixed it all without realizing it 😅 |
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.
- "Select all" checkbox appropriately appears and updates.
- Chevron next to the checkbox is visually appropriate (sizing, spacing, etc.).
✅ Approved
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/components/Table/TableComponents/TableHeader.tsx (3 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/components/Table/TableComponents/TableHeader.tsx
From a UX perspective I think we are missing a "deselect all rows" option. If the user selects all rows and then decides to unselect them then he/she is forced to go to every page and deselect them. For tables with many pages that's not very usable. |
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.
There seems to be an issue with the "Clear all selections" option. All my comments are related to that.
</> | ||
) : ( | ||
<> | ||
{translations.selectAll} ({rows.length}) |
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 also need an menu option to clear all selected rows. See my comments about UX in this PR.
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.
@@ -20,7 +20,10 @@ export const translations: ITableTranslations = { | |||
header: { | |||
clearSort: "Clear Sort", | |||
filterColumn: "Filter Column", | |||
selectAll: "select all", | |||
clearSelection: "Clear all selections", |
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 never saw this string in all my testing. Is it missing from your logic? Perhaps a bug?
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.
This is not included in this PR. It will be added in the next one.
Updated
Updated |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/components/Table/helpers/default-data.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/components/Table/helpers/default-data.ts
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/components/Table/Table.test.jsx (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/components/Table/Table.test.jsx
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.
Looks good to me.
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- src/components/Table/TableComponents/TableHeader.tsx (3 hunks)
- src/components/Table/helpers/default-data.ts (1 hunks)
- src/components/Table/types/TranslationTypes.ts (1 hunks)
Files skipped from review as they are similar to previous changes (3)
- src/components/Table/TableComponents/TableHeader.tsx
- src/components/Table/helpers/default-data.ts
- src/components/Table/types/TranslationTypes.ts
Updated |
Link to updated Table story
Before tagging the team for a review, I have done the following:
yarn all
locally: ensures that all tests pass, formatting is done, types pass, and builds passaxe Dev Tools
, Mac's VoiceOver, etc.)@avaya-dux/dux-design
if any visual changes have occurred@avaya-dux/dux-devs
This makes several updates to row selection in the Table component. Most notably that the header checkbox now selects/deselects the page's rows, not the entire tables.
Figma link
@avaya-dux/dux-design
: Review table selection visuals.@avaya-dux/dux-devs
: Review table selection logic.<button>
s. We'll need to figure out how to fix that soon.Summary by CodeRabbit