Skip to content

Commit

Permalink
perf: make submenus lazier
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook committed Aug 18, 2023
1 parent e9b477c commit a2d661c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/menu/src/MenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export class MenuItem extends LikeAnchor(
return slot;
}
import('@spectrum-web-components/overlay/sp-overlay.js');
import('@spectrum-web-components/popover/sp-popover.js');
return html`
<sp-overlay
.triggerElement=${this as HTMLElement}
Expand Down
2 changes: 2 additions & 0 deletions packages/menu/test/submenu.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ describe('Submenu', () => {
);

await elementUpdated(el);
await nextFrame();
await nextFrame();
const rootItem = el.querySelector('.root') as MenuItem;
const rootItemBoundingRect = rootItem.getBoundingClientRect();
expect(rootItem.open).to.be.false;
Expand Down
4 changes: 2 additions & 2 deletions packages/picker/src/Picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ import type {
MenuItem,
MenuItemChildren,
} from '@spectrum-web-components/menu';
import '@spectrum-web-components/tray/sp-tray.js';
import '@spectrum-web-components/popover/sp-popover.js';
import { Placement } from '@spectrum-web-components/overlay';
import {
IS_MOBILE,
Expand Down Expand Up @@ -480,6 +478,7 @@ export class PickerBase extends SizedMixin(Focusable) {
// @todo: test in mobile
/* c8 ignore next 11 */
if (this.isMobile.matches) {
import('@spectrum-web-components/tray/sp-tray.js');
return html`
<sp-tray
id="popover"
Expand All @@ -490,6 +489,7 @@ export class PickerBase extends SizedMixin(Focusable) {
</sp-tray>
`;
}
import('@spectrum-web-components/popover/sp-popover.js');
return html`
<sp-popover
id="popover"
Expand Down
2 changes: 2 additions & 0 deletions packages/picker/sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ governing permissions and limitations under the License.
*/

import '@spectrum-web-components/overlay/sp-overlay.js';
import '@spectrum-web-components/tray/sp-tray.js';
import '@spectrum-web-components/popover/sp-popover.js';

0 comments on commit a2d661c

Please sign in to comment.