Skip to content

Commit fad81c0

Browse files
committed
feat: accept popupId: null in types
1 parent b5cbe0e commit fad81c0

File tree

6 files changed

+381
-11
lines changed

6 files changed

+381
-11
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"@types/glob": "^8.0.0",
5858
"@types/mocha": "^10.0.6",
5959
"@types/node": "^18.11.13",
60+
"@types/sinon": "^17.0.3",
6061
"@typescript-eslint/eslint-plugin": "^7.6.0",
6162
"@typescript-eslint/parser": "^7.6.0",
6263
"@typescript-eslint/typescript-estree": "^5.46.0",
@@ -81,7 +82,7 @@
8182
"react": "^18.2.0",
8283
"react-dom": "^18.2.0",
8384
"rimraf": "^3.0.2",
84-
"sinon": "^6.1.4",
85+
"sinon": "^6.3.5",
8586
"typescript": "^5.1.0",
8687
"webpack": "^5.75.0",
8788
"webpack-cli": "^5.0.1",

pnpm-lock.yaml

Lines changed: 23 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/hooks.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type Variant = 'popover' | 'popper' | 'dialog'
2626

2727
export type PopupState = {
2828
open: (eventOrAnchorEl?: SyntheticEvent | Element | null) => void
29-
close: () => void
29+
close: (eventOrAnchorEl?: SyntheticEvent | Element | null) => void
3030
toggle: (eventOrAnchorEl?: SyntheticEvent | Element | null) => void
3131
onBlur: (event: FocusEvent) => void
3232
onMouseLeave: (event: MouseEvent) => void
@@ -82,7 +82,7 @@ export function usePopupState({
8282
disableAutoFocus,
8383
}: {
8484
parentPopupState?: PopupState | null | undefined
85-
popupId?: string
85+
popupId?: string | null
8686
variant: Variant
8787
disableAutoFocus?: boolean | null | undefined
8888
}): PopupState {
@@ -281,7 +281,7 @@ export function usePopupState({
281281
const popupState: PopupState = {
282282
...state,
283283
setAnchorEl,
284-
popupId,
284+
popupId: popupId ?? undefined,
285285
variant,
286286
open,
287287
close,

src/useEvent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react'
22

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

0 commit comments

Comments
 (0)