Skip to content

Commit

Permalink
feat: narrow tagName type
Browse files Browse the repository at this point in the history
This was too wide, allowing for non-HTML element tags like `svg`, which cause runtime errors.

Closes #251
  • Loading branch information
psychedelicious committed Dec 30, 2023
1 parent 7c9ebcc commit 5fe1e84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/react-resizable-panels/src/Panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type ImperativePanelHandle = {
resize: (size: number) => void;
};

export type PanelProps = Omit<HTMLAttributes<ElementType>, "id" | "onResize"> &
export type PanelProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id" | "onResize"> &
PropsWithChildren<{
className?: string;
collapsedSize?: number | undefined;
Expand All @@ -68,7 +68,7 @@ export type PanelProps = Omit<HTMLAttributes<ElementType>, "id" | "onResize"> &
onResize?: PanelOnResize;
order?: number;
style?: object;
tagName?: ElementType;
tagName?: keyof HTMLElementTagNameMap;
}>;

export function PanelWithForwardedRef({
Expand Down
4 changes: 2 additions & 2 deletions packages/react-resizable-panels/src/PanelGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const defaultStorage: PanelGroupStorage = {
},
};

export type PanelGroupProps = Omit<HTMLAttributes<ElementType>, "id"> &
export type PanelGroupProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id"> &
PropsWithChildren<{
autoSaveId?: string | null;
className?: string;
Expand All @@ -78,7 +78,7 @@ export type PanelGroupProps = Omit<HTMLAttributes<ElementType>, "id"> &
onLayout?: PanelGroupOnLayout | null;
storage?: PanelGroupStorage;
style?: CSSProperties;
tagName?: ElementType;
tagName?: keyof HTMLElementTagNameMap;
}>;

const debounceMap: {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-resizable-panels/src/PanelResizeHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import { getCursorStyle } from "./utils/cursor";

export type PanelResizeHandleOnDragging = (isDragging: boolean) => void;

export type PanelResizeHandleProps = Omit<HTMLAttributes<ElementType>, "id"> &
export type PanelResizeHandleProps = Omit<HTMLAttributes<keyof HTMLElementTagNameMap>, "id"> &
PropsWithChildren<{
className?: string;
disabled?: boolean;
id?: string | null;
onDragging?: PanelResizeHandleOnDragging;
style?: CSSProperties;
tabIndex?: number;
tagName?: ElementType;
tagName?: keyof HTMLElementTagNameMap;
}>;

export function PanelResizeHandle({
Expand Down

0 comments on commit 5fe1e84

Please sign in to comment.