Skip to content

Commit 29debc8

Browse files
committed
🩹 harsher padWithNItems limit to ensure picker scrolls in all scenarios
1 parent 50519a7 commit 29debc8

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

src/components/DurationScroll/index.tsx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
145145
setClickSound(sound);
146146
}
147147
};
148+
148149
loadSound();
149150

150151
// Unload sound when component unmounts
@@ -154,27 +155,6 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
154155
// eslint-disable-next-line react-hooks/exhaustive-deps
155156
}, [Audio]);
156157

157-
useImperativeHandle(ref, () => ({
158-
reset: (options) => {
159-
flatListRef.current?.scrollToIndex({
160-
animated: options?.animated ?? false,
161-
index: initialScrollIndex,
162-
});
163-
},
164-
setValue: (value, options) => {
165-
flatListRef.current?.scrollToIndex({
166-
animated: options?.animated ?? false,
167-
index: getInitialScrollIndex({
168-
numberOfItems,
169-
padWithNItems,
170-
repeatNumbersNTimes: safeRepeatNumbersNTimes,
171-
value: value,
172-
}),
173-
});
174-
},
175-
latestDuration: latestDuration,
176-
}));
177-
178158
const renderItem = useCallback(
179159
({ item }: { item: string }) => {
180160
let stringItem = item;
@@ -401,6 +381,27 @@ const DurationScroll = forwardRef<DurationScrollRef, DurationScrollProps>(
401381
},
402382
]);
403383

384+
useImperativeHandle(ref, () => ({
385+
reset: (options) => {
386+
flatListRef.current?.scrollToIndex({
387+
animated: options?.animated ?? false,
388+
index: initialScrollIndex,
389+
});
390+
},
391+
setValue: (value, options) => {
392+
flatListRef.current?.scrollToIndex({
393+
animated: options?.animated ?? false,
394+
index: getInitialScrollIndex({
395+
numberOfItems,
396+
padWithNItems,
397+
repeatNumbersNTimes: safeRepeatNumbersNTimes,
398+
value: value,
399+
}),
400+
});
401+
},
402+
latestDuration: latestDuration,
403+
}));
404+
404405
return (
405406
<View
406407
pointerEvents={isDisabled ? "none" : undefined}

src/components/TimerPicker/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const TimerPicker = forwardRef<TimerPickerRef, TimerPickerProps>(
5555
return 0;
5656
}
5757

58-
const maxPadWithNItems = hideHours ? 30 : 12;
58+
const maxPadWithNItems = hideHours ? 15 : 6;
5959

6060
if (padWithNItems > maxPadWithNItems) {
6161
return maxPadWithNItems;

0 commit comments

Comments
 (0)