-
Notifications
You must be signed in to change notification settings - Fork 23
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
base: main
Are you sure you want to change the base?
fix: shift select #4636
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@ultraviolet/ui": patch | ||
--- | ||
|
||
`<List />` and `<Table />`: more intuitive behavior for shift+click |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,9 +231,10 @@ export const Row = forwardRef<HTMLTableRowElement, RowProps>( | |
registerSelectableRow, | ||
selectedRowIds, | ||
expandButton, | ||
mapCheckbox, | ||
inRange, | ||
columns, | ||
refList, | ||
handleOnChange, | ||
} = useListContext() | ||
|
||
const theme = useTheme() | ||
|
@@ -277,16 +278,13 @@ export const Row = forwardRef<HTMLTableRowElement, RowProps>( | |
const canClickRowToExpand = !disabled && !!expandable && !expandButton | ||
|
||
useEffect(() => { | ||
const refAtEffectStart = refList.current | ||
const { current } = checkboxRef | ||
|
||
if (current) { | ||
mapCheckbox.set(id, current) | ||
if (refAtEffectStart && current && !refAtEffectStart.includes(current)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. !refAtEffectStart.includes(current) it's work ? |
||
refList.current.push(current) | ||
} | ||
|
||
return () => { | ||
mapCheckbox.delete(id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is done somewhere else (l.199 of |
||
} | ||
}, [mapCheckbox, id]) | ||
}, [refList]) | ||
|
||
const childrenLength = | ||
Children.count(children) + (selectable ? 1 : 0) + (expandButton ? 1 : 0) | ||
|
@@ -341,6 +339,7 @@ export const Row = forwardRef<HTMLTableRowElement, RowProps>( | |
ref={checkboxRef} | ||
disabled={isSelectDisabled} | ||
inRange={inRange?.has(id)} | ||
onChange={() => handleOnChange(id, selectedRowIds[id])} | ||
/> | ||
</Tooltip> | ||
</StyledCheckboxContainer> | ||
|
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.
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