Skip to content

Commit

Permalink
feat: accept popupId: null in types
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Aug 29, 2024
1 parent b5cbe0e commit fad81c0
Show file tree
Hide file tree
Showing 6 changed files with 381 additions and 11 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"@types/glob": "^8.0.0",
"@types/mocha": "^10.0.6",
"@types/node": "^18.11.13",
"@types/sinon": "^17.0.3",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"@typescript-eslint/typescript-estree": "^5.46.0",
Expand All @@ -81,7 +82,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^3.0.2",
"sinon": "^6.1.4",
"sinon": "^6.3.5",
"typescript": "^5.1.0",
"webpack": "^5.75.0",
"webpack-cli": "^5.0.1",
Expand Down
24 changes: 23 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export type Variant = 'popover' | 'popper' | 'dialog'

export type PopupState = {
open: (eventOrAnchorEl?: SyntheticEvent | Element | null) => void
close: () => void
close: (eventOrAnchorEl?: SyntheticEvent | Element | null) => void
toggle: (eventOrAnchorEl?: SyntheticEvent | Element | null) => void
onBlur: (event: FocusEvent) => void
onMouseLeave: (event: MouseEvent) => void
Expand Down Expand Up @@ -82,7 +82,7 @@ export function usePopupState({
disableAutoFocus,
}: {
parentPopupState?: PopupState | null | undefined
popupId?: string
popupId?: string | null
variant: Variant
disableAutoFocus?: boolean | null | undefined
}): PopupState {
Expand Down Expand Up @@ -281,7 +281,7 @@ export function usePopupState({
const popupState: PopupState = {
...state,
setAnchorEl,
popupId,
popupId: popupId ?? undefined,
variant,
open,
close,
Expand Down
1 change: 1 addition & 0 deletions src/useEvent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'

export function useEvent<Fn extends (...args: any[]) => any>(handler: Fn): Fn {
// istanbul ignore next
if (typeof window === 'undefined') {
// useLayoutEffect doesn't work on the server side, don't bother
// trying to make callback functions stable
Expand Down
Loading

0 comments on commit fad81c0

Please sign in to comment.