@tangible/ui 0.2.30 → 0.2.32

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.
@@ -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
- restoreRef.current = document.activeElement;
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("aside", { ref: sidebarRef, className: rootClassName, "data-position": position, tabIndex: -1, children: children }) })] }) }));
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
@@ -202,7 +215,10 @@ function SidebarRoot(props) {
202
215
  function SidebarHeader(props) {
203
216
  const { children, className } = props;
204
217
  const headerClassName = ['tui-sidebar__header', className].filter(Boolean).join(' ');
205
- return _jsx("header", { className: headerClassName, children: children });
218
+ // A div, not <header>: outside a sectioning element <header> maps to
219
+ // banner, and a drawer's dialog doesn't scope it, so an open drawer added a
220
+ // second banner to the page. Inside the static <aside> it was generic anyway.
221
+ return _jsx("div", { className: headerClassName, children: children });
206
222
  }
207
223
  // =============================================================================
208
224
  // Sidebar.Footer
@@ -210,7 +226,8 @@ function SidebarHeader(props) {
210
226
  function SidebarFooter(props) {
211
227
  const { children, className } = props;
212
228
  const footerClassName = ['tui-sidebar__footer', className].filter(Boolean).join(' ');
213
- return _jsx("footer", { className: footerClassName, children: children });
229
+ // A div for the same reason as Sidebar.Header: <footer> maps to contentinfo.
230
+ return _jsx("div", { className: footerClassName, children: children });
214
231
  }
215
232
  // =============================================================================
216
233
  // Sidebar.Nav
package/figma-tokens.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.30",
2
+ "version": "0.2.32",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangible/ui",
3
- "version": "0.2.30",
3
+ "version": "0.2.32",
4
4
  "description": "Tangible Design System",
5
5
  "type": "module",
6
6
  "main": "./components/index.js",
package/tui-manifest.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "0.2.30",
3
- "generated": "2026-10-24T23:31:09.605Z",
2
+ "version": "0.2.32",
3
+ "generated": "2026-10-25T18:59:01.108Z",
4
4
  "components": {
5
5
  "Accordion": {
6
6
  "props": {