+ { ...otherProps }
+ >
+
+
{ children }
diff --git a/packages/components/src/modal/style.scss b/packages/components/src/modal/style.scss
index 426d9aef972ad..e529a072fe84c 100644
--- a/packages/components/src/modal/style.scss
+++ b/packages/components/src/modal/style.scss
@@ -7,10 +7,18 @@
left: 0;
background-color: rgba($white, 0.4);
z-index: z-index(".components-modal__screen-overlay");
+
+ // Animate appearance.
+ @include fade-in();
}
// The modal window element.
.components-modal__frame {
+ border: $border-width solid $light-gray-500;
+ background-color: $white;
+ box-shadow: $shadow-modal;
+ outline: none;
+
// In small screens the content needs to be full width.
position: fixed;
top: 0;
@@ -30,6 +38,9 @@
top: $panel-padding;
left: 50%;
height: 90%;
+
+ // Animate appearance.
+ @include modal_appear();
}
// Show pretty big on desktop breakpoints.
@@ -40,50 +51,61 @@
left: 50%;
height: 70%;
}
-
- border: $border-width solid $light-gray-500;
- background-color: $white;
- box-shadow: $shadow-modal;
- outline: none;
}
+// Fix heading to the top.
.components-modal__header {
box-sizing: border-box;
- height: $header-height;
border-bottom: $border-width solid $light-gray-500;
- padding: $item-spacing $item-spacing $item-spacing $panel-padding;
+ padding: 0 0 $grid-size 0;
display: flex;
flex-direction: row;
align-items: stretch;
justify-content: space-between;
-}
+ position: fixed;
+ top: 0;
+ background: $white;
+ width: calc(100% - #{$panel-padding + $panel-padding});
+ height: $header-height;
+ padding: $item-spacing 0;
-.components-modal__header-heading-container {
- align-items: center;
- flex-grow: 1;
- display: flex;
- flex-direction: row;
- justify-content: left;
-}
+ .components-modal__header-heading {
+ font-size: 1em;
+ font-weight: normal;
+ }
-.components-modal__header-heading {
- font-size: 1em;
- font-weight: normal;
-}
+ .components-modal__header-heading-container {
+ align-items: center;
+ flex-grow: 1;
+ display: flex;
+ flex-direction: row;
+ justify-content: left;
+ }
-.components-modal__header-icon-container {
- display: inline-block;
+ .components-modal__header-icon-container {
+ display: inline-block;
- svg {
- max-width: $icon-button-size;
- max-height: $icon-button-size;
- padding: 8px;
+ svg {
+ max-width: $icon-button-size;
+ max-height: $icon-button-size;
+ padding: 8px;
+ }
+ }
+
+ h1 {
+ line-height: 1;
+ margin: 0;
}
}
+// Modal contents.
.components-modal__content {
- // The height of the content is the height of it's parent, minus the header. after that, the offset was 3px.
- height: 100%;
+ box-sizing: border-box;
overflow: auto;
- padding: $panel-padding;
+ height: 100%;
+ padding: ($header-height+$panel-padding) $panel-padding $panel-padding $panel-padding;
+
+ &:focus {
+ outline: $border-width solid $dark-gray-500;
+ }
}
diff --git a/test/e2e/specs/a11y.test.js b/test/e2e/specs/a11y.test.js
index 704ae68bba49e..4534a8ac23dac 100644
--- a/test/e2e/specs/a11y.test.js
+++ b/test/e2e/specs/a11y.test.js
@@ -31,17 +31,17 @@ describe( 'a11y', () => {
} );
it( 'constrains focus to a modal when tabbing', async () => {
- // Open help modal
+ // Open keyboard help modal.
await pressWithModifier( ACCESS_MODIFIER_KEYS, 'h' );
- // Test that the Close button of the modal is focused when the
- // latter is opened.
- expect( await isCloseButtonFocused() ).toBe( true );
+ // The close button should not be focused by default; this is a strange UX
+ // experience.
+ // See: https://github.com/WordPress/gutenberg/issues/9410
+ expect( await isCloseButtonFocused() ).toBe( false );
await page.keyboard.press( 'Tab' );
- // Test that the Close button of the modal is focused when the
- // latter is opened.
+ // Ensure the Close button of the modal is focused after tabbing.
expect( await isCloseButtonFocused() ).toBe( true );
} );