-
Notifications
You must be signed in to change notification settings - Fork 246
chore(components): upgrade LeafyGreen modal components COMPASS-9642 #7594
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit
Hold shift + click to select a range
d9894b2
Upgrade LG modal packages
kraenhansen 8096983
Fix Modal to adopt LG Modal v20
kraenhansen 1a79dee
Fix connection-form to work around LG Modal v20
kraenhansen baf002b
Update generative-ai to adopt marketing-modal v7
kraenhansen 9fc6af6
Fix compass-import-export to work around LG modal v20
kraenhansen e1855b4
Update compass-welcome to adopt marketing-modal v7
kraenhansen c5274cb
Update compass-explain-plan to LG Modal v20
kraenhansen 37a6cc7
Fix compass-crud to adopt LG modal v20
kraenhansen 5f418d2
Update compass-schema to LG Modal v20
kraenhansen 65831d9
Add workaround for jsdom missing HTMLDialogElement support
kraenhansen 09eb31d
Update generative-ai to adopt LG modal v20
kraenhansen cd281f6
Fix fullScreen prop on derived Modal
kraenhansen 21f3682
Remove use of deprecated backdropClassName
kraenhansen aa0f76f
Remove workaround for MarketingModal button disabling
kraenhansen 5cc4946
Fix remaining components tests
kraenhansen 5ae783d
Revert workaround for LG-5593
kraenhansen 669e0cd
Update existing tests to handle dialog elements remaining in the DOM
kraenhansen e473a04
Update databases-collections to allow immediate removal of the heading
kraenhansen 01c66a3
Update e2e tests to use waitForDisplayed over waitForExist as this is…
kraenhansen b343940
Update e2e tests removing [role=dialog] from confirm dialog selectors
kraenhansen 3cdb6c7
Update e2e tests to wait for bulk delete modal to disappear
kraenhansen ad72a99
Update e2e tests to wait for connection form to be non-clickable in a…
kraenhansen 5e5ce3b
Update e2e tests to fix modal regressions
kraenhansen 2778a71
Disable pointer events on a closed modal
kraenhansen d1fe84b
Disable auto-focus on confirmation modal children by default
kraenhansen 6ab317e
Add new modal specific commands
kraenhansen 70e7015
Update E2E tests to use new modal commands instead of waitForDisplayed
kraenhansen f839793
Default initialFocus to "null" to avoid breaking existing modals
kraenhansen cf032a1
Wait for confirm button to show instead of simply expecting it
kraenhansen bb6ff36
Update FocusMode tests to handle LG Modal v20
kraenhansen 3799746
Update SettingsModal tests to handle LG Modal v20
kraenhansen 7ca774e
Clarify disabling the @typescript-eslint/no-namespace and add a TODO …
kraenhansen de78fec
Partial revert of ddd6d70dd59fbe8f948ea6e5ef80b6d478bc1eff
kraenhansen 920efc6
Fix auto-focus in bulk update and delete modals
kraenhansen 2f73260
Correcting sizing styles
kraenhansen c2e5d46
Correcting sizing styles more
kraenhansen 9646d87
Use named imports
kraenhansen d43fc16
Upgrade confirm-modal package
kraenhansen dbe7574
Fix useConfirmation's confirmButtonProps types
kraenhansen 9767e4f
Update use of ConfirmationModal
kraenhansen 564fc1e
Set initial focus on cancel (fallback to confirm) button
kraenhansen 6fa377d
Fix package lock
kraenhansen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Disable auto-focus on confirmation modal children by default
- Loading branch information
commit d1fe84b9236ae6877e66cf82cb9e7071c80ab167
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
packages/compass-components/src/hooks/use-error-details.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import { | ||
| render, | ||
| screen, | ||
| waitFor, | ||
| within, | ||
| userEvent, | ||
| } from '@mongodb-js/testing-library-compass'; | ||
| import { expect } from 'chai'; | ||
| import React from 'react'; | ||
|
|
||
| import { ConfirmationModalArea } from './use-confirmation'; | ||
| import { showErrorDetails } from './use-error-details'; | ||
|
|
||
| describe('use-error-details', function () { | ||
| context('showErrorDetails global function', function () { | ||
| let modal: HTMLElement; | ||
| beforeEach(async function () { | ||
| render( | ||
| <ConfirmationModalArea> | ||
| <button | ||
| type="button" | ||
| onClick={() => { | ||
| showErrorDetails({ | ||
| details: { oh: 'noes' }, | ||
| closeAction: 'back', | ||
| }); | ||
| }} | ||
| > | ||
| Open Modal | ||
| </button> | ||
| </ConfirmationModalArea> | ||
| ); | ||
| userEvent.click(screen.getByText('Open Modal')); | ||
| await waitFor(() => { | ||
| modal = screen.getByTestId('confirmation-modal'); | ||
| }); | ||
| }); | ||
|
|
||
| it('renders modal with cancel button focused', function () { | ||
| expect(within(modal).getByText('Error details')).to.exist; | ||
| const confirmElement = within(modal).getByText('Back'); | ||
| expect(confirmElement).to.exist; | ||
| expect(confirmElement.parentElement).to.equal(document.activeElement); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ export const showErrorDetails = function showErrorDetails({ | |
| buttonText: closeAction.replace(/\b\w/g, (c) => c.toUpperCase()), | ||
| confirmButtonProps: { | ||
| variant: ButtonVariant.Default, | ||
| autoFocus: true, | ||
| }, | ||
| initialFocus: '[data-testid=lg-confirmation_modal-footer-confirm_button]', | ||
|
||
| }); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
testid is a test-only value (and even there should be used sparingly), is there a way we can implement this without relying on test-only data attributes? Pass an actual id to confirmButtonProps for example?
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.
We might be able to generate an id, pass it through the props of the cancel button and use that as a selector here 🤔
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.
So .. because the
confirmButtonPropsandcancelButtonPropsare both based onBaseButtonProps, it's not possible to pass anid🙄 I've asked the LG team on slack if there's a reason for that. We could leave it as-is or generate atestidin the mean time? In any case, this is a workaround until https://jira.mongodb.org/browse/LG-5735 gets resolved.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.
Seems the LG team picked this up rather quickly and there's an issue LG-5794 with a PR is already in review: mongodb/leafygreen-ui#3362
We might be able to get this pulled in as part of this PR 👍
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 PR on leafygreen side is still open, but based on the changes there looks like you can already pass a normal id, it's just a type error at the moment, can we remove the usage of test-only functionality for the feature behavior and add a
@ts-expect-errorhere? Then next time we update, we will be able to spot it and clean-up, it's easier than tracking the TODO comments