Skip to content

Commit f8d43ac

Browse files
committed
chore: not provide data-menu-id when not ready
1 parent f6d124b commit f8d43ac

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/MenuItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const InternalMenuItem = (props: MenuItemProps) => {
200200
elementRef={elementRef}
201201
role={role === null ? 'none' : role || 'menuitem'}
202202
tabIndex={disabled ? null : -1}
203-
data-menu-id={overflowDisabled ? null : domDataId}
203+
data-menu-id={overflowDisabled && domDataId ? null : domDataId}
204204
{...restProps}
205205
{...activeProps}
206206
{...optionRoleProps}

src/SubMenu/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const InternalSubMenu = (props: SubMenuProps) => {
230230
};
231231

232232
// =============================== Render ===============================
233-
const popupId = `${domDataId}-popup`;
233+
const popupId = domDataId && `${domDataId}-popup`;
234234

235235
// >>>>> Title
236236
let titleNode: React.ReactElement = (
@@ -241,7 +241,7 @@ const InternalSubMenu = (props: SubMenuProps) => {
241241
tabIndex={mergedDisabled ? null : -1}
242242
ref={elementRef}
243243
title={typeof title === 'string' ? title : null}
244-
data-menu-id={overflowDisabled ? null : domDataId}
244+
data-menu-id={overflowDisabled && domDataId ? null : domDataId}
245245
aria-expanded={open}
246246
aria-haspopup
247247
aria-controls={popupId}

src/context/IdContext.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import * as React from 'react';
33
export const IdContext = React.createContext<string>(null);
44

55
export function getMenuId(uuid: string, eventKey: string) {
6+
if (uuid === undefined) {
7+
return null;
8+
}
69
return `${uuid}-${eventKey}`;
710
}
811

0 commit comments

Comments
 (0)