Skip to content

Commit 01f7df2

Browse files
authoredMar 11, 2024
fix(core): remove prev and next month buttons in calendar input (#5931)
* fix(core): remove prev and next month buttons in calendar input * fix(core): clean up unused labels
1 parent f42ea79 commit 01f7df2

File tree

1 file changed

+1
-36
lines changed
  • packages/sanity/src/core/form/inputs/DateInputs/base/calendar

1 file changed

+1
-36
lines changed
 

‎packages/sanity/src/core/form/inputs/DateInputs/base/calendar/Calendar.tsx

+1-36
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,7 @@ export const Calendar = forwardRef(function Calendar(
202202
<Flex>
203203
<Box flex={1}>
204204
<CalendarMonthSelect
205-
moveFocusedDate={moveFocusedDate}
206205
onChange={handleFocusedMonthChange}
207-
labels={{
208-
goToPreviousMonth: labels.goToPreviousMonth,
209-
goToNextMonth: labels.goToNextMonth,
210-
}}
211206
monthNames={labels.monthNames}
212207
value={focusedDate?.getMonth()}
213208
/>
@@ -333,34 +328,14 @@ function CalendarTimePresetButton(props: {
333328
}
334329

335330
function CalendarMonthSelect(props: {
336-
moveFocusedDate: (by: number) => void
337331
onChange: (e: FormEvent<HTMLSelectElement>) => void
338332
value?: number
339333
monthNames: MonthNames
340-
labels: {
341-
goToPreviousMonth: string
342-
goToNextMonth: string
343-
}
344334
}) {
345-
const {moveFocusedDate, onChange, value, labels, monthNames} = props
346-
347-
const handlePrevMonthClick = useCallback(() => moveFocusedDate(-1), [moveFocusedDate])
348-
349-
const handleNextMonthClick = useCallback(() => moveFocusedDate(1), [moveFocusedDate])
335+
const {onChange, value, monthNames} = props
350336

351337
return (
352338
<Flex flex={1} gap={1}>
353-
<Button
354-
aria-label={labels.goToPreviousMonth}
355-
onClick={handlePrevMonthClick}
356-
mode="bleed"
357-
icon={ChevronLeftIcon}
358-
tooltipProps={{content: 'Previous month'}}
359-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
360-
// @ts-ignore - Button with specific styling requirements
361-
{...CALENDAR_ICON_BUTTON_PROPS}
362-
/>
363-
364339
<Box flex={1}>
365340
<Select fontSize={1} radius={2} value={value} onChange={onChange} padding={2}>
366341
{monthNames.map((monthName, i) => (
@@ -371,16 +346,6 @@ function CalendarMonthSelect(props: {
371346
))}
372347
</Select>
373348
</Box>
374-
<Button
375-
aria-label={labels.goToNextMonth}
376-
mode="bleed"
377-
icon={ChevronRightIcon}
378-
onClick={handleNextMonthClick}
379-
tooltipProps={{content: 'Next month'}}
380-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
381-
// @ts-ignore - Button with specific styling requirements
382-
{...CALENDAR_ICON_BUTTON_PROPS}
383-
/>
384349
</Flex>
385350
)
386351
}

0 commit comments

Comments
 (0)
Please sign in to comment.