@westpac/ui 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @westpac/ui
2
2
 
3
+ ## 1.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - a55faea: set a default portalContainer for MultiSelect so styles render correctly in more situations without providing portalContainer
8
+
3
9
  ## 1.1.1
4
10
 
5
11
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import React, { useContext } from 'react';
2
+ import React, { useContext, useMemo } from 'react';
3
3
  import { DismissButton, mergeProps, Overlay, usePopover } from 'react-aria';
4
4
  import { MultiSelectContext } from '../../multi-select.component.js';
5
5
  import { styles as popoverStyles } from './multi-select-popover.styles.js';
@@ -16,11 +16,16 @@ export function MultiSelectPopover({ children, className, ...props }) {
16
16
  shouldCloseOnInteractOutside: ()=>false,
17
17
  offset: 6
18
18
  }, overlayState);
19
+ const brandContainer = useMemo(()=>{
20
+ if (typeof window !== 'undefined') {
21
+ return document.querySelector('[data-theme]') || document.querySelector('[class^="theme-"], [class*=" theme-"]') || document.body;
22
+ }
23
+ }, []);
19
24
  const width = (_buttonRef_current = buttonRef.current) === null || _buttonRef_current === void 0 ? void 0 : _buttonRef_current.getBoundingClientRect().width;
20
25
  const styles = popoverStyles();
21
26
  return React.createElement(Overlay, {
22
27
  disableFocusManagement: true,
23
- portalContainer: portalContainer
28
+ portalContainer: portalContainer || brandContainer
24
29
  }, React.createElement("div", {
25
30
  ...mergeProps(popoverProps, overlayProps),
26
31
  ref: popoverRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@westpac/ui",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import React, { useContext } from 'react';
3
+ import React, { useContext, useMemo } from 'react';
4
4
  import { DismissButton, mergeProps, Overlay, usePopover } from 'react-aria';
5
5
 
6
6
  import { MultiSelectContext } from '../../multi-select.component.js';
@@ -27,11 +27,22 @@ export function MultiSelectPopover({ children, className, ...props }: MultiSelec
27
27
  overlayState,
28
28
  );
29
29
 
30
+ // This is required so branding applies correctly by default due to portal location, can be overridden with portalContainer prop
31
+ const brandContainer = useMemo(() => {
32
+ if (typeof window !== 'undefined') {
33
+ return (
34
+ document.querySelector('[data-theme]') ||
35
+ document.querySelector('[class^="theme-"], [class*=" theme-"]') ||
36
+ document.body
37
+ );
38
+ }
39
+ }, []);
40
+
30
41
  const width = buttonRef.current?.getBoundingClientRect().width;
31
42
  const styles = popoverStyles();
32
43
 
33
44
  return (
34
- <Overlay disableFocusManagement portalContainer={portalContainer}>
45
+ <Overlay disableFocusManagement portalContainer={portalContainer || brandContainer}>
35
46
  <div
36
47
  {...mergeProps(popoverProps, overlayProps)}
37
48
  ref={popoverRef}