-
Notifications
You must be signed in to change notification settings - Fork 377
Closed
Milestone
Description
Describe the problem
When providing a description to a Modal and setting the id property, the DOM will have two div's with an identical id.
How do you reproduce the problem?
A codesandbox
Or basically:
<Modal
title="Basic modal"
id="basic-modal"
isOpen={isModalOpen}
onClose={handleModalToggle}
description={<p>description</p>}
actions={[
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
Confirm
</Button>,
<Button key="cancel" variant="link" onClick={handleModalToggle}>
Cancel
</Button>
]}
ouiaId="BasicModal"
>
Expected behavior
There should only be one id in the DOM.
Is this issue blocking you?
Not at the moment.
Screenshots
What is your environment?
Any.
What is your product and what release date are you targeting?
Cockpit.
Any other information?
Looking at the code, it seems to be caused by the line below, as if there is no description, the id descriptorId instead of the passed id via props. (As the props of Modal` are passed down everywhere).
Actually no, it should not remove the !description check, as otherwise you'd get a duplicate id (again).
const modalBody = hasNoBodyWrapper ? (
children
) : (
<ModalBoxBody
aria-label={bodyAriaLabel}
role={bodyAriaRole || defaultModalBodyAriaRole}
{...props}
{...(!description && !ariaDescribedby && { id: descriptorId })}
>
{children}
</ModalBoxBody>
);Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Done
