Skip to content

Conversation

dreamwasp
Copy link
Contributor

@dreamwasp dreamwasp commented Sep 25, 2025

Overview

Updates to the Modal, Dialog, and Alert components to encapsulate props for the closeButton in a single object.
Currently using props like hideCloseButton and disableCloseButton — with this update, these props and ref, tip, and tipAlignment are stored in a closeButtonProps prop.

PR Checklist

  • Related to designs:
  • Related to JIRA ticket: [GM-1313]
  • I have run this code to verify it works
  • This PR includes unit tests for the code change
  • This PR includes testing instructions tests for the code change
  • The alpha package of this PR is passing end-to-end tests in all relevant Codecademy repositories

Testing Instructions

Don't make me tap the sign.

  1. Go to Modal and go to the "Close behavior" section
  2. Notice that the close Button's tip is customized (Check it with VO)
  3. Tab + click/enter/space through the buttons in the first canvas
  4. scroll down to the "Focus management" section
  5. Tab + click/enter/space through the buttons in the examples
  6. Go to Dialog and go to the "Close behavior" section
  7. Notice that the close Button's tip is customized (Check it with VO)
  8. Tab + click/enter/space through the buttons in the first canvas
  9. Go to Alert and go to the "Close button props" section
  10. Notice the close Buttons now available (the 2nd example is actually dismissible)
  11. Scroll down to "Close button customization" and see that the tip and the alignment has been customized
  12. (optional) check out the new tests
  13. Finish and do a celebratory dance

PR Links and Envs

Repository PR Link
Monolith Monolith PR
Mono Mono PR

@dreamwasp dreamwasp changed the title feat(ModalProps): add new accessibility props to Modal feat(ModalProps)!: add new accessibility props to Modal Sep 25, 2025
Copy link

nx-cloud bot commented Sep 25, 2025

View your CI Pipeline Execution ↗ for commit 384da96

Command Status Duration Result
nx run-many --target=verify --parallel=3 --all ✅ Succeeded <1s View ↗
nx run-many --target=build --all ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2025-10-03 19:01:58 UTC

@LinKCoding LinKCoding changed the title feat(ModalProps)!: add new accessibility props to Modal feat(Modal, Dialog, and Alert)!: add new accessibility props to Modal, Dialog, and Alert's close Button Oct 1, 2025
@LinKCoding LinKCoding marked this pull request as ready for review October 1, 2025 16:08
@LinKCoding LinKCoding requested a review from a team as a code owner October 1, 2025 16:08
Copy link
Contributor

@aresnik11 aresnik11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! A couple small questions/nits

chokidar "^3.4.0"

"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.24.7", "@babel/code-frame@^7.25.9", "@babel/code-frame@^7.26.0", "@babel/code-frame@^7.27.1":
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.24.7", "@babel/code-frame@^7.27.1":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have all of these yarn.lock changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure — but I do the get same result on your ajr-nested-checkboxes branch by running
npx yarn-deduplicate and then yarn 🤔

I wonder if it's like Cass did this after I did my emotion bump b.c. a lotta packages were still duped? 🤷

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah maybe, lets just double check with them on monday


<Canvas of={ModalStories.CloseButtonCustomization} />

If the close button is hidden, you will need to create a custom way to close the modal. You can then use the `isOpen` prop to create other controls that toggle the Modal on and off.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add this line to all the other stories?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this to Dialog, but wondering if it's necessary for Alert — since the onClose prop kinda forces the user to implement the close logic and not sure if we'd want to encourage folks to work around that


<Canvas of={ModalStories.Scrollable} />

## Focus management
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add this section to all the other stories?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ended up not doing this for Alert, but would like to confirm with Cass about some Alert specific things
e.g. do we need all those closeButtonProps, or is it really just the text and alignment.

Comment on lines 184 to 199
export const CustomClose: React.FC = () => {
const [isOpen, setIsOpen] = useState(false);
return (
<>
<FillButton onClick={() => setIsOpen(true)}>Open Modal</FillButton>
<Modal
{...defaultProps}
closeButtonProps={{ hidden: true }}
isOpen={isOpen}
onRequestClose={() => setIsOpen(false)}
>
Close the Modal!
</Modal>
</>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know this is existing but should we have a button or something to close the modal in this example? its for custom close but were not showing a custom close

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added for both Modal and Dialog (tho lmk about Dialog b.c. both the Accept/Confirm buttons do close the Dialog lol)

);
};

export const FocusManagement: React.FC = () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not totally clear what this example is doing tbh, the 2 buttons dont seem to do anything different unless i'm missing something

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were you using keyboard (tab + space/enter)?
when I was using mouse it doesn't really show anything lol

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure, ill try again when i rereview!

@codecademydev
Copy link
Collaborator

📬Published Alpha Packages:

@codecademy/[email protected]
@codecademy/[email protected]
@codecademy/[email protected]

@codecademydev
Copy link
Collaborator

🚀 Styleguide deploy preview ready!

https://68e01e91694c74048107c2ee--gamut-preview.netlify.app

Deploy Logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants