diff --git a/apps/client/src/widgets/buttons/calendar.ts b/apps/client/src/widgets/buttons/calendar.ts index 731678cd1..60b372fee 100644 --- a/apps/client/src/widgets/buttons/calendar.ts +++ b/apps/client/src/widgets/buttons/calendar.ts @@ -62,26 +62,6 @@ export default class CalendarWidget extends RightDropdownButtonWidget { } }); - // Year navigation - this.$yearSelect = this.$dropdownContent.find('[data-calendar-input="year"]'); - this.$yearSelect.on("input", (e) => { - const target = e.target as HTMLInputElement; - this.date = this.date.year(parseInt(target.value)); - this.createMonth(); - }); - - this.$nextYear = this.$dropdownContent.find('[data-calendar-toggle="nextYear"]'); - this.$nextYear.on("click", () => { - this.date = this.date.add(1, 'year'); - this.createMonth(); - }); - - this.$previousYear = this.$dropdownContent.find('[data-calendar-toggle="previousYear"]'); - this.$previousYear.on("click", () => { - this.date = this.date.subtract(1, 'year'); - this.createMonth(); - }); - // Date click this.$dropdownContent.on("click", ".calendar-date", async (ev) => { const date = $(ev.target).closest(".calendar-date").attr("data-calendar-date"); diff --git a/apps/client/src/widgets/launch_bar/CalendarWidget.tsx b/apps/client/src/widgets/launch_bar/CalendarWidget.tsx index f1cdfe20b..2fcceb571 100644 --- a/apps/client/src/widgets/launch_bar/CalendarWidget.tsx +++ b/apps/client/src/widgets/launch_bar/CalendarWidget.tsx @@ -6,7 +6,6 @@ import appContext from "../../components/app_context"; import "./CalendarWidget.css"; import Calendar from "./Calendar"; import ActionButton from "../react/ActionButton"; -import Dropdown from "../react/Dropdown"; import { t } from "../../services/i18n"; import FormDropdownList from "../react/FormDropdownList"; import FormTextBox from "../react/FormTextBox"; @@ -82,6 +81,7 @@ function CalendarMonthSelector({ date, setDate }: CalendarHeaderProps) { onChange={value => { }} + buttonProps={{ "data-calendar-input": "month" }} /> diff --git a/apps/client/src/widgets/react/Dropdown.tsx b/apps/client/src/widgets/react/Dropdown.tsx index c0f5f5585..fbafda25e 100644 --- a/apps/client/src/widgets/react/Dropdown.tsx +++ b/apps/client/src/widgets/react/Dropdown.tsx @@ -1,11 +1,16 @@ import { Dropdown as BootstrapDropdown } from "bootstrap"; -import { ComponentChildren } from "preact"; +import { ComponentChildren, HTMLAttributes } from "preact"; import { CSSProperties, HTMLProps } from "preact/compat"; import { useCallback, useEffect, useRef, useState } from "preact/hooks"; import { useUniqueName } from "./hooks"; +type DataAttributes = { + [key: `data-${string}`]: string | number | boolean | undefined; +}; + export interface DropdownProps extends Pick, "id" | "className"> { buttonClassName?: string; + buttonProps?: Partial & DataAttributes>; isStatic?: boolean; children: ComponentChildren; title?: string; @@ -24,7 +29,7 @@ export interface DropdownProps extends Pick, "id" | "c dropdownOptions?: Partial; } -export default function Dropdown({ id, className, buttonClassName, isStatic, children, title, text, dropdownContainerStyle, dropdownContainerClassName, hideToggleArrow, iconAction, disabled, noSelectButtonStyle, noDropdownListStyle, forceShown, onShown: externalOnShown, onHidden: externalOnHidden, dropdownOptions }: DropdownProps) { +export default function Dropdown({ id, className, buttonClassName, isStatic, children, title, text, dropdownContainerStyle, dropdownContainerClassName, hideToggleArrow, iconAction, disabled, noSelectButtonStyle, noDropdownListStyle, forceShown, onShown: externalOnShown, onHidden: externalOnHidden, dropdownOptions, buttonProps }: DropdownProps) { const dropdownRef = useRef(null); const triggerRef = useRef(null); @@ -80,6 +85,7 @@ export default function Dropdown({ id, className, buttonClassName, isStatic, chi title={title} id={id ?? ariaId} disabled={disabled} + {...buttonProps} > {text}