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: pick shouldn't strictly equal #6541

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/picker-view/wheel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const Wheel = memo<Props>(
useIsomorphicLayoutEffect(() => {
if (draggingRef.current) return
if (value === null) return
const targetIndex = column.findIndex(item => item.value === value)
const targetIndex = column.findIndex(item => item.value == value)
Copy link
Member

Choose a reason for hiding this comment

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

永远都不应该使用 ==

Copy link
Author

Choose a reason for hiding this comment

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

那或者将value默认转换成number呢

if (targetIndex < 0) return
const finalPosition = targetIndex * -itemHeight.current
api.start({ y: finalPosition, immediate: y.goal !== finalPosition })
Expand All @@ -71,7 +71,7 @@ export const Wheel = memo<Props>(
onSelect(null)
}
} else {
if (!column.some(item => item.value === value)) {
if (!column.some(item => item.value == value)) {
const firstItem = column[0]
onSelect(firstItem.value)
}
Expand Down Expand Up @@ -269,7 +269,7 @@ export const Wheel = memo<Props>(
aria-hidden
>
{column.map((item, index) => {
const selected = props.value === item.value
const selected = props.value == item.value
if (selected) selectedIndex = index
function handleClick() {
draggingRef.current = false
Expand All @@ -278,7 +278,7 @@ export const Wheel = memo<Props>(
return (
<div
key={item.key ?? item.value}
data-selected={item.value === value}
data-selected={item.value == value}
className={`${classPrefix}-column-item`}
onClick={handleClick}
aria-hidden={!selected}
Expand Down
Loading