@tangible/ui 0.2.30 → 0.2.31
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/components/Sidebar/Sidebar.js +16 -3
- package/figma-tokens.json +1 -1
- package/package.json +1 -1
- package/tui-manifest.json +2 -2
|
@@ -81,6 +81,9 @@ function SidebarRoot(props) {
|
|
|
81
81
|
setVisible(true);
|
|
82
82
|
}, [open]);
|
|
83
83
|
const isClosing = drawer && !open && visible;
|
|
84
|
+
// Read by the animationend handler, which must only act on the slide-out.
|
|
85
|
+
const isClosingRef = useRef(isClosing);
|
|
86
|
+
isClosingRef.current = isClosing;
|
|
84
87
|
const shouldRender = drawer && (open || visible);
|
|
85
88
|
// Dismiss: set visible false and restore focus to the element that opened
|
|
86
89
|
// the drawer. Called from both the reduced-motion layout effect and the
|
|
@@ -110,8 +113,12 @@ function SidebarRoot(props) {
|
|
|
110
113
|
dismiss();
|
|
111
114
|
}
|
|
112
115
|
}, [isClosing, dismiss]);
|
|
116
|
+
// The panel animates in as well as out. Only the slide-out ends the drawer:
|
|
117
|
+
// reacting to the slide-in's animationend moved focus back to the trigger
|
|
118
|
+
// ~200ms after opening, and cleared restoreRef so a later close restored
|
|
119
|
+
// nothing.
|
|
113
120
|
const handleAnimationEnd = useCallback((e) => {
|
|
114
|
-
if (e.target === panelRef.current) {
|
|
121
|
+
if (e.target === panelRef.current && isClosingRef.current) {
|
|
115
122
|
dismiss();
|
|
116
123
|
}
|
|
117
124
|
}, [dismiss]);
|
|
@@ -125,7 +132,13 @@ function SidebarRoot(props) {
|
|
|
125
132
|
useLayoutEffect(() => {
|
|
126
133
|
if (!drawer || !isBrowser || !open)
|
|
127
134
|
return;
|
|
128
|
-
|
|
135
|
+
// Re-opened mid slide-out, focus is still inside the panel: keep the
|
|
136
|
+
// trigger captured on the first open rather than saving a node about to
|
|
137
|
+
// unmount.
|
|
138
|
+
const active = document.activeElement;
|
|
139
|
+
if (panelRef.current?.contains(active))
|
|
140
|
+
return;
|
|
141
|
+
restoreRef.current = active;
|
|
129
142
|
}, [drawer, open]);
|
|
130
143
|
// ---------------------------------------------------------------------------
|
|
131
144
|
// Drawer mode: body scroll lock
|
|
@@ -194,7 +207,7 @@ function SidebarRoot(props) {
|
|
|
194
207
|
]
|
|
195
208
|
.filter(Boolean)
|
|
196
209
|
.join(' ');
|
|
197
|
-
return (_jsx(SidebarCollapseContext.Provider, { value: collapseContext, children: _jsxs("div", { className: drawerClassName, "data-position": position, "data-state": drawerState, children: [_jsx("div", { className: "tui-sidebar-drawer__backdrop", onClick: onClose, "aria-hidden": "true" }), _jsx("div", { ref: panelRef, className: "tui-sidebar-drawer__panel", role: "dialog", "aria-modal": "true", "aria-label": ariaLabel, onAnimationEnd: handleAnimationEnd, children: _jsx("
|
|
210
|
+
return (_jsx(SidebarCollapseContext.Provider, { value: collapseContext, children: _jsxs("div", { className: drawerClassName, "data-position": position, "data-state": drawerState, children: [_jsx("div", { className: "tui-sidebar-drawer__backdrop", onClick: onClose, "aria-hidden": "true" }), _jsx("div", { ref: panelRef, className: "tui-sidebar-drawer__panel", role: "dialog", "aria-modal": "true", "aria-label": ariaLabel, onAnimationEnd: handleAnimationEnd, children: _jsx("div", { ref: sidebarRef, className: rootClassName, "data-position": position, tabIndex: -1, children: children }) })] }) }));
|
|
198
211
|
}
|
|
199
212
|
// =============================================================================
|
|
200
213
|
// Sidebar.Header
|
package/figma-tokens.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
2
|
+
"version": "0.2.31",
|
|
3
3
|
"source": "publish/styles/all.expanded.css",
|
|
4
4
|
"prefix": "tui-",
|
|
5
5
|
"note": "Layer 1 primitives only. Component API tokens (--tui-{component}-*) are never defined in CSS — they exist only as fallback reads — so they have no Figma representation. CONTRACT: consumers read TUI defaults from this file at build time (variables[].cssVar, the \"Light\"/\"Dark\" mode names, and alias chains into TUI/Primitives). Renaming a cssVar or a mode is a breaking change to those consumers even when the CSS value is unchanged — a rename silently becomes an undefined default downstream — so treat it as at least a minor bump and call it out in the CHANGELOG.",
|
package/package.json
CHANGED
package/tui-manifest.json
CHANGED