Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update react types to avoid unbound method lint errors #3480

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/@headlessui-react/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ let DialogContext = createContext<
{
dialogState: DialogStates
unmount: boolean
close(): void
setTitleId(id: string | null): void
close: () => void
setTitleId: (id: string | null) => void
},
StateDefinition,
]
Expand Down Expand Up @@ -340,7 +340,7 @@ export type DialogProps<TTag extends ElementType = typeof DEFAULT_DIALOG_TAG> =
DialogPropsWeControl,
PropsForFeatures<typeof DialogRenderFeatures> & {
open?: boolean
onClose(value: boolean): void
onClose: (value: boolean) => void
initialFocus?: MutableRefObject<HTMLElement | null>
role?: 'dialog' | 'alertdialog'
autoFocus?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function useDisclosureContext(component: string) {
}

let DisclosureAPIContext = createContext<{
close(focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>): void
close: (focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>) => void
} | null>(null)
DisclosureAPIContext.displayName = 'DisclosureAPIContext'

Expand Down Expand Up @@ -163,7 +163,7 @@ function stateReducer(state: StateDefinition, action: Actions) {
let DEFAULT_DISCLOSURE_TAG = Fragment
type DisclosureRenderPropArg = {
open: boolean
close(focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>): void
close: (focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>) => void
}
type DisclosurePropsWeControl = never

Expand Down
18 changes: 9 additions & 9 deletions packages/@headlessui-react/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ function usePopoverContext(component: string) {
}

let PopoverAPIContext = createContext<{
close(
close: (
focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null> | MouseEvent<HTMLElement>
): void
) => void
isPortalled: boolean
} | null>(null)
PopoverAPIContext.displayName = 'PopoverAPIContext'
Expand All @@ -195,10 +195,10 @@ function usePopoverAPIContext(component: string) {
}

let PopoverGroupContext = createContext<{
registerPopover(registerBag: PopoverRegisterBag): void
unregisterPopover(registerBag: PopoverRegisterBag): void
isFocusWithinPopoverGroup(): boolean
closeOthers(buttonId: string): void
registerPopover: (registerBag: PopoverRegisterBag) => void
unregisterPopover: (registerBag: PopoverRegisterBag) => void
isFocusWithinPopoverGroup: () => boolean
closeOthers: (buttonId: string) => void
} | null>(null)
PopoverGroupContext.displayName = 'PopoverGroupContext'

Expand All @@ -216,7 +216,7 @@ function usePopoverPanelContext() {
interface PopoverRegisterBag {
buttonId: MutableRefObject<string | null>
panelId: MutableRefObject<string | null>
close(): void
close: () => void
}
function stateReducer(state: StateDefinition, action: Actions) {
return match(action.type, reducers, state, action)
Expand All @@ -227,9 +227,9 @@ function stateReducer(state: StateDefinition, action: Actions) {
let DEFAULT_POPOVER_TAG = 'div' as const
type PopoverRenderPropArg = {
open: boolean
close(
close: (
focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null> | MouseEvent<HTMLElement>
): void
) => void
}
type PopoverPropsWeControl = never

Expand Down