diff --git a/apps/browser/src/platform/popup/layout/popup-layout.mdx b/apps/browser/src/platform/popup/layout/popup-layout.mdx index 017ee20b344..a2725350a8f 100644 --- a/apps/browser/src/platform/popup/layout/popup-layout.mdx +++ b/apps/browser/src/platform/popup/layout/popup-layout.mdx @@ -54,6 +54,9 @@ page looks nice when the extension is popped out. `false`. - `loadingText` - Custom text to be applied to the loading element for screenreaders only. Defaults to "Loading". +- `disablePadding` + - When `true`, disables the padding of the scrollable region inside of `main`. You will need to + add your own padding to the element you place inside of this area. Basic usage example: @@ -169,6 +172,22 @@ When the browser extension is popped out, the "popout" button should not be pass +## With Virtual Scroll + +If you are using a virtual scrolling container inside of the popup page, you'll want to apply the +`bitScrollLayout` directive to the `cdk-virtual-scroll-viewport` element. This tells the virtual +scroll viewport to use the popup page's scroll layout div as the scrolling container. + +See the code in the example below. + + + +### Known Virtual Scroll Issues + +See [Virtual Scrolling](?path=/docs/documentation-virtual-scrolling--docs#known-footgun) for more +information about how to structure virtual scrolling containers with layout components and avoid a +known issue with template construction. + # Other stories ## Centered Content diff --git a/apps/browser/src/platform/popup/layout/popup-layout.stories.ts b/apps/browser/src/platform/popup/layout/popup-layout.stories.ts index aecbaf673dc..894ab13dd19 100644 --- a/apps/browser/src/platform/popup/layout/popup-layout.stories.ts +++ b/apps/browser/src/platform/popup/layout/popup-layout.stories.ts @@ -1,5 +1,4 @@ -// FIXME: Update this file to be type safe and remove this and next line -// @ts-strict-ignore +import { ScrollingModule } from "@angular/cdk/scrolling"; import { CommonModule } from "@angular/common"; import { Component, importProvidersFrom } from "@angular/core"; import { RouterModule } from "@angular/router"; @@ -20,6 +19,7 @@ import { NoItemsModule, SearchModule, SectionComponent, + ScrollLayoutDirective, } from "@bitwarden/components"; import { PopupRouterCacheService } from "../view-cache/popup-router-cache.service"; @@ -39,6 +39,17 @@ import { PopupTabNavigationComponent } from "./popup-tab-navigation.component"; }) class ExtensionContainerComponent {} +@Component({ + selector: "extension-popped-container", + template: ` +
+ +
+ `, + standalone: true, +}) +class ExtensionPoppedContainerComponent {} + @Component({ selector: "vault-placeholder", template: /*html*/ ` @@ -295,6 +306,7 @@ export default { decorators: [ moduleMetadata({ imports: [ + ScrollLayoutDirective, PopupTabNavigationComponent, PopupHeaderComponent, PopupPageComponent, @@ -302,6 +314,7 @@ export default { CommonModule, RouterModule, ExtensionContainerComponent, + ExtensionPoppedContainerComponent, MockBannerComponent, MockSearchComponent, MockVaultSubpageComponent, @@ -312,6 +325,11 @@ export default { MockVaultPagePoppedComponent, NoItemsModule, VaultComponent, + ScrollingModule, + ItemModule, + SectionComponent, + IconButtonModule, + BadgeModule, ], providers: [ { @@ -495,7 +513,21 @@ export const CompactMode: Story = { const compact = canvasEl.querySelector( `#${containerId} [data-testid=popup-layout-scroll-region]`, ); + + if (!compact) { + // eslint-disable-next-line + console.error(`#${containerId} [data-testid=popup-layout-scroll-region] not found`); + return; + } + const label = canvasEl.querySelector(`#${containerId} .example-label`); + + if (!label) { + // eslint-disable-next-line + console.error(`#${containerId} .example-label not found`); + return; + } + const percentVisible = 100 - Math.round((100 * (compact.scrollHeight - compact.clientHeight)) / compact.scrollHeight); @@ -510,9 +542,9 @@ export const PoppedOut: Story = { render: (args) => ({ props: args, template: /* HTML */ ` -
+ -
+ `, }), }; @@ -560,10 +592,9 @@ export const TransparentHeader: Story = { template: /* HTML */ ` - 🤠 Custom Content - + + 🤠 Custom Content + @@ -608,3 +639,56 @@ export const WidthOptions: Story = { `, }), }; + +export const WithVirtualScrollChild: Story = { + render: (args) => ({ + props: { ...args, data: Array.from(Array(20).keys()) }, + template: /* HTML */ ` + + + + + + @defer (on immediate) { + + + + + + + + + + + + + + + + + + + + } + + + + `, + }), +}; diff --git a/apps/browser/src/platform/popup/layout/popup-page.component.html b/apps/browser/src/platform/popup/layout/popup-page.component.html index 2313b942a38..b53ef6e97eb 100644 --- a/apps/browser/src/platform/popup/layout/popup-page.component.html +++ b/apps/browser/src/platform/popup/layout/popup-page.component.html @@ -1,29 +1,39 @@
+
+
-
- -
+
- +