Skip to content

Commit fde8fad

Browse files
fix: align practice
1 parent 663937f commit fde8fad

File tree

1 file changed

+33
-36
lines changed

1 file changed

+33
-36
lines changed

src/PickerInput/Selector/Input.tsx

Lines changed: 33 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -333,47 +333,44 @@ const Input = React.forwardRef<InputRef, InputProps>((props, ref) => {
333333
// ======================== Format ========================
334334
const rafRef = React.useRef<number>();
335335

336-
useLayoutEffect(
337-
function () {
338-
if (!focused || !format) {
339-
return;
340-
}
336+
useLayoutEffect(() => {
337+
if (!focused || !format) {
338+
return;
339+
}
341340

342-
// Reset with format if not match (always apply when focused so mask works when focusing by mousedown)
343-
if (!maskFormat.match(inputValue)) {
344-
triggerInputChange(format);
345-
return;
346-
}
341+
// Reset with format if not match (always apply when focused so mask works when focusing by mousedown)
342+
if (!maskFormat.match(inputValue)) {
343+
triggerInputChange(format);
344+
return;
345+
}
347346

348-
// When mousedown get focus, defer selection to mouseUp so click position is used
349-
if (mouseDownRef.current) {
350-
return;
351-
}
347+
// When mousedown get focus, defer selection to mouseUp so click position is used
348+
if (mouseDownRef.current) {
349+
return;
350+
}
352351

353-
// Match the selection range
354-
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
352+
// Match the selection range
353+
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
355354

356-
// Chrome has the bug anchor position looks not correct but actually correct
357-
rafRef.current = raf(() => {
358-
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
359-
});
355+
// Chrome has the bug anchor position looks not correct but actually correct
356+
rafRef.current = raf(() => {
357+
inputRef.current.setSelectionRange(selectionStart, selectionEnd);
358+
});
360359

361-
return () => {
362-
raf.cancel(rafRef.current);
363-
};
364-
},
365-
[
366-
maskFormat,
367-
format,
368-
focused,
369-
inputValue,
370-
focusCellIndex,
371-
selectionStart,
372-
selectionEnd,
373-
forceSelectionSyncMark,
374-
triggerInputChange,
375-
],
376-
);
360+
return () => {
361+
raf.cancel(rafRef.current);
362+
};
363+
}, [
364+
maskFormat,
365+
format,
366+
focused,
367+
inputValue,
368+
focusCellIndex,
369+
selectionStart,
370+
selectionEnd,
371+
forceSelectionSyncMark,
372+
triggerInputChange,
373+
]);
377374

378375
// ======================== Render ========================
379376
// Input props for format

0 commit comments

Comments
 (0)