Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
erwan committed Nov 25, 2024
2 parents 5e9e664 + 8415d60 commit 8943490
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions packages/react/components/range/Range.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Range = React.forwardRef(
className={hashClass(clsx('range-cursor range-cursor-min'))}
onMouseUp={handleMouseUpMin}
onChange={handleChangeCursorMin}
onTouchEnd={handleMouseUpMin}
value={cursorMin}
type='range'
min={min}
Expand All @@ -81,6 +82,7 @@ const Range = React.forwardRef(
className={hashClass(clsx('range-cursor range-cursor-max'))}
onMouseUp={handleMouseUpMax}
onChange={handleChangeCursorMax}
onTouchEnd={handleMouseUpMax}
value={cursorMax}
type='range'
min={min}
Expand Down
9 changes: 4 additions & 5 deletions packages/react/components/range/hook/useRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@ export const useRange = ({
try {
const [cursorMin, setCursorMin] = React.useState<number>(valueCursorMin ?? 0)
const [cursorMax, setCursorMax] = React.useState<number>(valueCursorMax ?? max)

const refTrack = React.useRef(null)

const handleChangeCursorMin = React.useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
if (Number(e.target.value) < cursorMax - gap) setCursorMin(Number(e.target.value))
},
[cursorMax, cursorMin],
[cursorMax, cursorMin, gap],
)

const handleChangeCursorMax = React.useCallback(
(e: React.ChangeEvent<HTMLInputElement>) => {
if (Number(e.target.value) > cursorMin + gap) setCursorMax(Number(e.target.value))
},
[cursorMax, cursorMin],
[cursorMax, cursorMin, gap],
)

const handleMouseUpMin = React.useCallback(() => {
Expand Down Expand Up @@ -71,15 +70,15 @@ export const useRange = ({
TrilogyColor.MAIN_FADE,
)} ${(cursorMax / max) * 100}%, ${getColorStyle(TrilogyColor.NEUTRAL_FADE)} ${(cursorMax / max) * 100}%) `
}
}, [cursorMin, cursorMax])
}, [cursorMin, cursorMax, refTrack, max])

React.useEffect(() => {
setCursorMin(valueCursorMin || 0)
}, [valueCursorMin])

React.useEffect(() => {
setCursorMax(valueCursorMax || max)
}, [valueCursorMax])
}, [valueCursorMax, max])

return {
refTrack,
Expand Down

0 comments on commit 8943490

Please sign in to comment.