Skip to content

Commit fb11ab9

Browse files
committed
Disable auto-focus on confirmation modal children by default
1 parent e0d5f3d commit fb11ab9

File tree

4 files changed

+5
-12
lines changed

4 files changed

+5
-12
lines changed

packages/compass-components/src/hooks/use-confirmation.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ export { ConfirmationModalVariant };
1818
type ConfirmationModalProps = React.ComponentProps<typeof ConfirmationModal>;
1919

2020
type ConfirmationProperties = Partial<
21-
Pick<ConfirmationModalProps, 'title' | 'variant' | 'requiredInputText'>
21+
Pick<
22+
ConfirmationModalProps,
23+
'title' | 'variant' | 'requiredInputText' | 'initialFocus'
24+
>
2225
> & {
2326
buttonText?: React.ReactNode;
2427
confirmButtonProps?: Omit<ButtonProps, 'onClick'>;
@@ -196,6 +199,7 @@ const ConfirmationModalStateHandler: React.FunctionComponent = ({
196199
onClick: handleCancel,
197200
}}
198201
requiredInputText={confirmationProps.requiredInputText ?? undefined}
202+
initialFocus={confirmationProps.initialFocus ?? null}
199203
>
200204
{confirmationProps.description}
201205
{confirmationProps.warning && (

packages/compass-e2e-tests/tests/collection-aggregations-tab.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,6 @@ describe('Collection aggregations tab', function () {
676676
const errorDetailsJson = browser.$(Selectors.ErrorDetailsJson);
677677
await errorDetailsJson.waitForDisplayed();
678678

679-
// exit details
680-
// leafygreen autofocus triggers a tooltip on the error code element,
681-
// "Tab" to remove the focus
682-
await browser.keys('Tab');
683679
// now click the close button
684680
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
685681
// wait for the modal to go away

packages/compass-e2e-tests/tests/collection-documents-tab.test.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -727,10 +727,6 @@ FindIterable<Document> result = collection.find(filter);`);
727727
const errorDetailsJson = browser.$(Selectors.ErrorDetailsJson);
728728
await errorDetailsJson.waitForDisplayed();
729729

730-
// exit details
731-
// leafygreen autofocus triggers a tooltip on the error code element,
732-
// "Tab" to remove the focus
733-
await browser.keys('Tab');
734730
// now click the close button
735731
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
736732
// wait for the modal to go away

packages/compass-e2e-tests/tests/collection-import.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,6 @@ describe('Collection import', function () {
595595
expect(await errorDetailsJson.getText()).to.include(
596596
'schemaRulesNotSatisfied'
597597
);
598-
// leafygreen autofocus triggers a tooltip on the error code element,
599-
// "Tab" to remove the focus
600-
await browser.keys('Tab');
601598
// now click the close button
602599
await browser.clickVisible(Selectors.confirmationModalConfirmButton());
603600
// wait for the modal to go away

0 commit comments

Comments
 (0)