Skip to content

Commit

Permalink
chore: fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Apr 18, 2024
1 parent 56bd4f5 commit 9a5468d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/Handles/Handle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export interface HandleProps
onOffsetChange: (value: number | 'min' | 'max', valueIndex: number) => void;
onFocus: (e: React.FocusEvent<HTMLDivElement>, index: number) => void;
onMouseEnter: (e: React.MouseEvent<HTMLDivElement>, index: number) => void;
render?: (origin: React.ReactElement<HandleProps>, props: RenderProps) => React.ReactElement;
render?: (
origin: React.ReactElement<React.HTMLAttributes<HTMLDivElement>>,
props: RenderProps,
) => React.ReactElement;
onChangeComplete?: () => void;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Handles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,13 @@ const Handles = React.forwardRef<HandlesRef, HandlesProps>((props, ref) => {
<Handle
key="a11y"
{...handleProps}
aria-hidden
value={values[activeIndex]}
valueIndex={0}
dragging={draggingIndex !== -1}
render={activeHandleRender}
style={{ pointerEvents: 'none' }}
tabIndex={-1}
aria-hidden
/>
)}
</>
Expand Down
5 changes: 3 additions & 2 deletions src/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,13 @@ const Slider = React.forwardRef<SliderRef, SliderProps<number | number[]>>((prop
};

const finishChange = () => {
onAfterChange?.(getTriggerValue(rawValuesRef.current));
const finishValue = getTriggerValue(rawValuesRef.current);
onAfterChange?.(finishValue);
warning(
!onAfterChange,
'[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead.',
);
onChangeComplete?.(getTriggerValue(rawValuesRef.current));
onChangeComplete?.(finishValue);
};

const [draggingIndex, draggingValue, cacheValues, onStartDrag] = useDrag(
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useDrag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function useDrag(
const mouseMoveEventRef = React.useRef<(event: MouseEvent) => void>(null);
const mouseUpEventRef = React.useRef<(event: MouseEvent) => void>(null);

React.useEffect(() => {
React.useLayoutEffect(() => {
if (draggingIndex === -1) {
setCacheValues(rawValues);
}
Expand Down

0 comments on commit 9a5468d

Please sign in to comment.