-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add modal button aria label and export ModalCloseButton #550
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ export type ModalProps = AriaModalOverlayProps & | |
isOpen: boolean | ||
onClose: () => void | ||
className?: string | ||
closeButtonAriaLabel?: string | ||
|
||
/** | ||
* https://github.com/adobe/react-spectrum/issues/3787 | ||
|
@@ -74,6 +75,7 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(function ModalInner( | |
onClose, | ||
className, | ||
isOpen = false, | ||
closeButtonAriaLabel = 'Close', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make this a prop for i18n |
||
} = props | ||
|
||
const ref = useObjectRef<HTMLDivElement>(external) | ||
|
@@ -162,9 +164,11 @@ const Modal = forwardRef<HTMLDivElement, ModalProps>(function ModalInner( | |
> | ||
{children} | ||
{isDismissable === true && ( | ||
<ModalCrossButton | ||
<ModalCloseButton | ||
size="S" | ||
icon="24/Close" | ||
type="button" | ||
aria-label={closeButtonAriaLabel} | ||
onClick={onClose} | ||
/> | ||
)} | ||
|
@@ -224,7 +228,7 @@ const ModalBackground = animated(styled.div<{ | |
} | ||
`) | ||
|
||
const ModalCrossButton = styled(IconButton)` | ||
export const ModalCloseButton = styled(IconButton)` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In case user want to set |
||
position: absolute; | ||
top: 8px; | ||
right: 8px; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes all
IconButton
s. If it's too broad to decide I'll make this a separate PR.