Skip to content
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

LF-4084: Update table/2 to include checkboxes and row selection behaviour #3149

Conversation

SayakaOno
Copy link
Collaborator

@SayakaOno SayakaOno commented Mar 1, 2024

Description

  • Update V2 table to support checkbox and sticky header and style selected rows
  • Add stories and cleanup

NOTE: I didn't apply the new checkbox style as it seems like it would require a good amount of effort.

Jira link: https://lite-farm.atlassian.net/browse/LF-4084

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Passes test case
  • UI components visually reviewed on desktop view
  • UI components visually reviewed on mobile view
  • Other (please explain)

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The precommit and linting ran successfully
  • I have added or updated language tags for text that's part of the UI
  • I have added "MISSING" for all new language tags to languages I don't speak
  • I have added the GNU General Public License to all new files

@SayakaOno SayakaOno added the enhancement New feature or request label Mar 1, 2024
@SayakaOno SayakaOno self-assigned this Mar 1, 2024
@SayakaOno SayakaOno marked this pull request as ready for review March 1, 2024 23:27
@SayakaOno SayakaOno requested review from a team as code owners March 1, 2024 23:27
@SayakaOno SayakaOno requested review from antsgar and Duncan-Brain and removed request for a team March 1, 2024 23:27
Duncan-Brain
Duncan-Brain previously approved these changes Mar 4, 2024
Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

It looks good to me!

I think the only thing I would consider adding is a clear all on the story when the select all is checked.

Comment on lines +96 to +97
onCheck,
handleSelectAllClick,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if these two could be combined and simplified by passing a setSelectedIds function prop instead, and letting the table handle the different scenarios where the selected IDs need to change

Copy link
Collaborator Author

@SayakaOno SayakaOno Mar 6, 2024

Choose a reason for hiding this comment

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

It's possible, but I'm hesitant to do it.
A few of my concerns:

  • flexibility - what if we want to do something else when checkbox is clicked?
  • duplicated handleSelectAllClick - we will have a function for this in its parent component anyways because we have "clear selection" in the action menu

Are they not a big deal??

Update:
I figured that handleSelectAllClick should be like this:

const handleSelectAllClick = (e) => {
  if (e.target.checked) {
    setSelectedIds(data.map(({ id }) => id));
  } else {
    setSelectedIds([]);
  }
};

Considering we will have to write this in parent components, I am not sure which is better...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Those are good points, this was just a suggestion but I think either way is alright!

@antsgar antsgar self-requested a review March 7, 2024 12:05
antsgar
antsgar previously approved these changes Mar 7, 2024
Copy link
Collaborator

@Duncan-Brain Duncan-Brain left a comment

Choose a reason for hiding this comment

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

@SayakaOno happy to approve but I think this morning the other table pr was merged so there are now conflicts

@SayakaOno SayakaOno requested a review from antsgar March 7, 2024 16:14
@SayakaOno SayakaOno added this pull request to the merge queue Mar 7, 2024
Merged via the queue into integration with commit 2ad4464 Mar 7, 2024
5 checks passed
@SayakaOno SayakaOno deleted the LF-4084/Update_TableV2_to_include_checkboxes_and_row_selection_behaviour branch March 7, 2024 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants