From 0585f7f30bf502d147bd467a942ee180656b2413 Mon Sep 17 00:00:00 2001 From: Westbrook Johnson Date: Wed, 24 Mar 2021 15:56:08 -0400 Subject: [PATCH] fix: correct max size calculation for overlays --- packages/picker/stories/picker.stories.ts | 20 +++++---- packages/popover/src/popover.css | 55 +++++------------------ 2 files changed, 21 insertions(+), 54 deletions(-) diff --git a/packages/picker/stories/picker.stories.ts b/packages/picker/stories/picker.stories.ts index ccb1cdd422..584c9c3853 100644 --- a/packages/picker/stories/picker.stories.ts +++ b/packages/picker/stories/picker.stories.ts @@ -269,15 +269,13 @@ export const custom = (args: StoryArgs): TemplateResult => { label="Pick a state" ...=${spreadProps(args)} > - - ${states.map( - (state) => html` - - ${state.label} - - ` - )} - + ${states.map( + (state) => html` + + ${state.label} + + ` + )}

This is some text.

This is some text.

@@ -288,3 +286,7 @@ export const custom = (args: StoryArgs): TemplateResult => {

`; }; + +custom.args = { + open: true, +}; diff --git a/packages/popover/src/popover.css b/packages/popover/src/popover.css index c8de509b30..661956228b 100644 --- a/packages/popover/src/popover.css +++ b/packages/popover/src/popover.css @@ -15,53 +15,18 @@ governing permissions and limitations under the License. --sp-popover-tip-size: 24px; } -:host([placement*='bottom'][open]) { - /* .spectrum-Popover--bottom.is-open */ - max-height: calc( - 100vh - - var( - --spectrum-dropdown-flyout-menu-offset-y, - var(--spectrum-global-dimension-size-75) - ) - ); +:host([placement*='top']), +:host([placement*='bottom']) { + max-height: calc(100% - var(--spectrum-overlay-animation-distance)); } -:host([placement*='top'][open]) { - /* .spectrum-Popover--top.is-open */ - margin-top: var( - --spectrum-dropdown-flyout-menu-offset-y, - var(--spectrum-global-dimension-size-75) - ); - max-height: calc( - 100vh - - var( - --spectrum-dropdown-flyout-menu-offset-y, - var(--spectrum-global-dimension-size-75) - ) - ); -} -:host([placement*='right'][open]) { - /* .spectrum-Popover--right.is-open */ - max-width: calc( - 100vw - - var( - --spectrum-dropdown-flyout-menu-offset-y, - var(--spectrum-global-dimension-size-75) - ) - ); + +:host([placement*='left']), +:host([placement*='right']) { + max-width: calc(100% - var(--spectrum-overlay-animation-distance)); } -:host([placement*='left'][open]) { - /* .spectrum-Popover--left.is-open */ - margin-left: var( - --spectrum-dropdown-flyout-menu-offset-y, - var(--spectrum-global-dimension-size-75) - ); - max-width: calc( - 100vw - - var( - --spectrum-dropdown-flyout-menu-offset-y, - var(--spectrum-global-dimension-size-75) - ) - ); + +::slotted(*) { + overscroll-behavior: contain; } /* provide dimensions */