@spaced-out/ui-design-system 0.3.49 → 0.3.50
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 +7 -0
- package/lib/components/AvatarGroup/AvatarGroup.js.flow +2 -2
- package/lib/components/ButtonDropdown/ButtonDropdown.js +22 -10
- package/lib/components/ButtonDropdown/ButtonDropdown.js.flow +58 -33
- package/lib/components/ButtonDropdown/ButtonDropdown.module.css +8 -1
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.js +3 -0
- package/lib/components/ButtonDropdown/SimpleButtonDropdown.js.flow +6 -1
- package/lib/components/ButtonTabs/ButtonTabDropdown.js +13 -6
- package/lib/components/ButtonTabs/ButtonTabDropdown.js.flow +40 -24
- package/lib/components/ButtonTabs/ButtonTabDropdown.module.css +4 -0
- package/lib/components/ButtonTabs/ButtonTabs.js +2 -0
- package/lib/components/ButtonTabs/ButtonTabs.js.flow +4 -0
- package/lib/components/Dropdown/Dropdown.js +23 -8
- package/lib/components/Dropdown/Dropdown.js.flow +57 -32
- package/lib/components/Dropdown/Dropdown.module.css +5 -0
- package/lib/components/Dropdown/SimpleDropdown.js +2 -0
- package/lib/components/Dropdown/SimpleDropdown.js.flow +4 -0
- package/lib/components/FilterButtonOverlay/FilterButtonOverlay.js +23 -8
- package/lib/components/FilterButtonOverlay/FilterButtonOverlay.js.flow +56 -26
- package/lib/components/InlineDropdown/InlineDropdown.js +25 -8
- package/lib/components/InlineDropdown/InlineDropdown.js.flow +57 -30
- package/lib/components/InlineDropdown/InlineDropdown.module.css +5 -0
- package/lib/components/InlineDropdown/SimpleInlineDropdown.js +2 -0
- package/lib/components/InlineDropdown/SimpleInlineDropdown.js.flow +4 -0
- package/lib/components/Table/StaticTable.js +1 -1
- package/lib/components/Table/StaticTable.js.flow +1 -1
- package/lib/components/Table/Table.docs.js +1 -1
- package/lib/components/Table/Table.docs.js.flow +1 -1
- package/lib/components/Tabs/TabList/TabDropdown.js +14 -7
- package/lib/components/Tabs/TabList/TabDropdown.js.flow +38 -22
- package/lib/components/Tabs/TabList/TabDropdown.module.css +4 -0
- package/lib/components/Tabs/TabList/TabList.js +4 -2
- package/lib/components/Tabs/TabList/TabList.js.flow +4 -0
- package/lib/components/TokenListInput/TokenListInput.js +26 -7
- package/lib/components/TokenListInput/TokenListInput.js.flow +58 -32
- package/lib/components/TokenListInput/TokenListInput.module.css +5 -0
- package/lib/components/Tooltip/Tooltip.js +2 -1
- package/lib/components/Tooltip/Tooltip.js.flow +2 -2
- package/lib/components/Typeahead/SimpleTypeahead.js +3 -1
- package/lib/components/Typeahead/SimpleTypeahead.js.flow +4 -0
- package/lib/components/Typeahead/Typeahead.js +25 -8
- package/lib/components/Typeahead/Typeahead.js.flow +58 -30
- package/lib/components/Typeahead/Typeahead.module.css +5 -0
- package/lib/hooks/index.js +11 -0
- package/lib/hooks/index.js.flow +1 -0
- package/lib/hooks/useReferenceElementWidth/index.js +16 -0
- package/lib/hooks/useReferenceElementWidth/index.js.flow +3 -0
- package/lib/hooks/useReferenceElementWidth/useReferenceElementWidth.js +21 -0
- package/lib/hooks/useReferenceElementWidth/useReferenceElementWidth.js.flow +23 -0
- package/lib/utils/click-away/click-away.js +4 -0
- package/lib/utils/click-away/click-away.js.flow +34 -0
- package/package.json +1 -1
|
@@ -36,6 +36,28 @@ export type ClickAwayProps = {
|
|
|
36
36
|
children: (props: ChildProps) => React.Node,
|
|
37
37
|
onChange?: (isOpen: boolean) => mixed,
|
|
38
38
|
clickAwayRef?: ClickAwayRefType,
|
|
39
|
+
/**
|
|
40
|
+
* When containsNestedFloatingPortals is true, prevents ClickAway from closing the dropdown if the click target
|
|
41
|
+
* is inside a floating portal root element.
|
|
42
|
+
*
|
|
43
|
+
* This is necessary for nested dropdowns rendered using floating portals,
|
|
44
|
+
* such as via `@floating-ui/react`. Floating portals render elements outside
|
|
45
|
+
* the normal DOM tree (often directly into `document.body` or another container)
|
|
46
|
+
* using `ReactDOM.createPortal`. As a result, these nested dropdowns do not
|
|
47
|
+
* appear inside the parent dropdown's `boundaryRef` or `triggerRef` subtree.
|
|
48
|
+
*
|
|
49
|
+
* To address this, the floating portal ensures that all nested dropdowns
|
|
50
|
+
* are mounted into a **shared root element** — effectively maintaining a
|
|
51
|
+
* common DOM ancestry. This allows parent dropdowns to detect when clicks
|
|
52
|
+
* occur within any of their nested children, even if rendered via portals.
|
|
53
|
+
* The shared root element is the closest parent element that has a `data-floating-ui-portal` attribute.
|
|
54
|
+
* Because of this, the ClickAway logic will not close the parent menu if the click target is inside boundaryRef's parentElement.
|
|
55
|
+
*
|
|
56
|
+
* Enabling `containsNestedFloatingPortals` allows the ClickAway logic to account
|
|
57
|
+
* for this shared root and avoids incorrectly closing the parent menu when
|
|
58
|
+
* interacting with nested dropdowns.
|
|
59
|
+
*/
|
|
60
|
+
containsNestedFloatingPortals?: boolean,
|
|
39
61
|
};
|
|
40
62
|
|
|
41
63
|
type ClickAwayState = {
|
|
@@ -48,8 +70,10 @@ type ClickAwayState = {
|
|
|
48
70
|
|
|
49
71
|
export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
50
72
|
static defaultProps: {
|
|
73
|
+
containsNestedFloatingPortals?: boolean,
|
|
51
74
|
closeOnEscapeKeypress?: boolean,
|
|
52
75
|
} = {
|
|
76
|
+
containsNestedFloatingPortals: false,
|
|
53
77
|
closeOnEscapeKeypress: true,
|
|
54
78
|
};
|
|
55
79
|
|
|
@@ -145,6 +169,16 @@ export class ClickAway extends React.Component<ClickAwayProps, ClickAwayState> {
|
|
|
145
169
|
};
|
|
146
170
|
|
|
147
171
|
handleCloseClick: (evt: MouseEvent) => void = (evt: MouseEvent) => {
|
|
172
|
+
if (
|
|
173
|
+
evt.target instanceof Node &&
|
|
174
|
+
this.props.containsNestedFloatingPortals &&
|
|
175
|
+
this.boundaryRef.current?.parentElement &&
|
|
176
|
+
(this.boundaryRef.current.parentElement === evt.target ||
|
|
177
|
+
this.boundaryRef.current.parentElement.contains(evt.target))
|
|
178
|
+
) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
148
182
|
if (
|
|
149
183
|
evt.target instanceof Node &&
|
|
150
184
|
this.boundaryRef &&
|