Skip to content

Commit 7b35299

Browse files
fix: <Tab> and <TabPanel> id type mismatch (#8423)
* fix: `<Tab>` and `<TabPanel>` `id` type mismatch * fix types * fix types --------- Co-authored-by: Robert Snow <[email protected]> Co-authored-by: Robert Snow <[email protected]>
1 parent 5684c90 commit 7b35299

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

packages/@react-spectrum/s2/src/Tabs.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ export function TabPanel(props: TabPanelProps): ReactNode | null {
458458
}
459459

460460
function CollapsedTabPanel(props: TabPanelProps) {
461-
let {UNSAFE_style, UNSAFE_className = '', ...otherProps} = props;
461+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
462+
let {UNSAFE_style, UNSAFE_className = '', id, ...otherProps} = props;
462463
let {menuId, valueId} = useContext(CollapseContext);
463464
let ref = useRef(null);
464465
let tabIndex = useHasTabbableChild(ref) ? undefined : 0;

packages/@react-types/tabs/src/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ interface AriaTabListBase extends AriaLabelingProps {
5555

5656
export interface AriaTabListProps<T> extends TabListProps<T>, AriaTabListBase, DOMProps, AriaLabelingProps {}
5757

58-
export interface AriaTabPanelProps extends DOMProps, AriaLabelingProps {}
58+
export interface AriaTabPanelProps extends Omit<DOMProps, 'id'>, AriaLabelingProps {
59+
/** The unique id of the tab. */
60+
id?: Key
61+
}
5962

6063
export interface SpectrumTabsProps<T> extends AriaTabListBase, Omit<SingleSelection, 'onSelectionChange'>, DOMProps, StyleProps {
6164
/** The children of the `<Tabs>` element. Should include `<TabList>` and `<TabPanels>` elements. */

packages/react-aria-components/src/Tabs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ export const Tab = /*#__PURE__*/ createLeafComponent('item', (props: TabProps, f
290290
export const TabPanel = /*#__PURE__*/ createHideableComponent(function TabPanel(props: TabPanelProps, forwardedRef: ForwardedRef<HTMLDivElement>) {
291291
const state = useContext(TabListStateContext)!;
292292
let ref = useObjectRef<HTMLDivElement>(forwardedRef);
293+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
294+
let {id, ...otherProps} = props;
293295
let {tabPanelProps} = useTabPanel(props, state, ref);
294296
let {focusProps, isFocused, isFocusVisible} = useFocusRing();
295297

@@ -310,7 +312,7 @@ export const TabPanel = /*#__PURE__*/ createHideableComponent(function TabPanel(
310312
return null;
311313
}
312314

313-
let DOMProps = filterDOMProps(props);
315+
let DOMProps = filterDOMProps(otherProps);
314316
delete DOMProps.id;
315317

316318
let domProps = isSelected

0 commit comments

Comments
 (0)