-
-
Notifications
You must be signed in to change notification settings - Fork 271
Open
Labels
component: menuChanges related to the menu component.Changes related to the menu component.component: popoverChanges related to the popover component.Changes related to the popover component.component: tooltipChanges related to the tooltip component.Changes related to the tooltip component.type: regressionA bug, but worse, it used to behave as expected.A bug, but worse, it used to behave as expected.
Description
Bug report
Current behavior
Base UI: Trigger must have an id prop specified.
Expected behavior
support react 17
Reproducible example
Base UI version
1.0.0-beta.6
Additional context
export function useTriggerRegistration(id: string | undefined) {
const [element, setElement] = React.useState<HTMLElement | null>(null);
useIsoLayoutEffect(() => {
if (id == null) {
if (element != null) {
throw new Error('Base UI: Trigger must have an `id` prop specified.');
}
return;
}
}, [element, id, store]);
}function useGlobalId(idOverride?: string, prefix: string = 'mui'): string | undefined {
const [defaultId, setDefaultId] = React.useState(idOverride);
const id = idOverride || defaultId;
React.useEffect(() => {
if (defaultId == null) {
// Fallback to this default id when possible.
// Use the incrementing value for client-side rendering only.
// We can't use it server-side.
// If you want to use random values please consider the Birthday Problem: https://en.wikipedia.org/wiki/Birthday_problem
globalId += 1;
setDefaultId(`${prefix}-${globalId}`);
}
}, [defaultId, prefix]);
return id;
}Metadata
Metadata
Assignees
Labels
component: menuChanges related to the menu component.Changes related to the menu component.component: popoverChanges related to the popover component.Changes related to the popover component.component: tooltipChanges related to the tooltip component.Changes related to the tooltip component.type: regressionA bug, but worse, it used to behave as expected.A bug, but worse, it used to behave as expected.