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

fix: shift select #4636

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

fix: shift select #4636

wants to merge 3 commits into from

Conversation

lisalupi
Copy link
Contributor

@lisalupi lisalupi commented Jan 3, 2025

Summary

Type

  • Enhancement

Summarise concisely:

What is expected?

Have a more intuitive behavior when shift+click on a selectable list/table (see 2. #4625)

The following changes where made:

  1. Removed hover behavior to replace with indexes

Before:

Enregistrement.de.l.ecran.2025-01-03.a.16.40.49.mov

After :

Enregistrement.de.l.ecran.2025-01-03.a.16.41.16.mov

@lisalupi lisalupi added the enhancement New feature or request label Jan 3, 2025
@lisalupi lisalupi requested a review from a team January 3, 2025 15:42
@lisalupi lisalupi self-assigned this Jan 3, 2025
@lisalupi lisalupi removed the request for review from a team January 3, 2025 15:42
@lisalupi lisalupi requested a review from matthprost as a code owner January 3, 2025 15:42
Copy link

changeset-bot bot commented Jan 3, 2025

🦋 Changeset detected

Latest commit: f846dcb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@ultraviolet/ui Patch
@ultraviolet/form Patch
@ultraviolet/plus Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

codecov bot commented Jan 3, 2025

Codecov Report

Attention: Patch coverage is 97.87234% with 1 line in your changes missing coverage. Please review.

Project coverage is 87.48%. Comparing base (0dc816f) to head (f846dcb).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
packages/ui/src/components/List/ListContext.tsx 97.22% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4636      +/-   ##
==========================================
+ Coverage   87.44%   87.48%   +0.03%     
==========================================
  Files         335      339       +4     
  Lines       12733    12821      +88     
  Branches     3528     3542      +14     
==========================================
+ Hits        11135    11217      +82     
- Misses       1598     1604       +6     
Files with missing lines Coverage Δ
packages/ui/src/components/List/Row.tsx 91.89% <100.00%> (ø)
packages/ui/src/components/Table/Row.tsx 74.68% <100.00%> (-1.27%) ⬇️
...s/ui/src/components/Table/__tests__/index.test.tsx 89.92% <100.00%> (-0.52%) ⬇️
packages/ui/src/components/List/ListContext.tsx 94.78% <97.22%> (-0.22%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 140e633...f846dcb. Read the comment docs.

Copy link
Collaborator

@matthprost matthprost left a comment

Choose a reason for hiding this comment

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

Why removing hover effect?

}

return () => {
mapCheckbox.delete(id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we must remove the checkbox of the refList.current when the row is delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is done somewhere else (l.199 of ListContext.tsx)

const { current } = checkboxRef

if (current) {
mapCheckbox.set(id, current)
if (refAtEffectStart && current && !refAtEffectStart.includes(current)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

!refAtEffectStart.includes(current)

it's work ?

Copy link
Collaborator

@fabienhebert fabienhebert left a comment

Choose a reason for hiding this comment

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

it should be ok for me after considering @philibea feedbacks

packages/ui/src/components/List/ListContext.tsx Outdated Show resolved Hide resolved
@lisalupi
Copy link
Contributor Author

lisalupi commented Jan 9, 2025

Why removing hover effect?

It was not intuitive & it is overridden by the new version of shift-select (similar to how it was before)

Comment on lines +275 to +281
useEffect(() => {
// Re-arrange refList everytime it is modified in order to keep the write order of the elements in it.
const allCheckboxes = [
...document.querySelectorAll('input[type="checkbox"]:not([value="all"])'),
].map(element => element as HTMLInputElement)
refList.current = allCheckboxes.map(checkbox => checkbox)
}, [refList.current.length])
Copy link
Collaborator

Choose a reason for hiding this comment

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

By doing this you take the risk to select every checkbox in the page. Let's say you have a 2 list in the same page you will select checkboxes for both list while only one is being edited.

We should avoid using a querySelector for interacting with the list / table

Comment on lines -173 to -183
useEffect(() => {
const { current } = checkboxRowRef

if (current) {
mapCheckbox.set(id, current)
}

return () => {
mapCheckbox.delete(id)
}
}, [mapCheckbox, id])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why changing this? Here you automatically register and unregister the checkbox ref into the list provider and update the list of it depending on rows. This is useful especially if you have dynamic rows which happens quite often (deleting an element, etc)

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.

5 participants