@noya-app/noya-designsystem 0.1.85 → 0.1.87

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noya-app/noya-designsystem",
3
- "version": "0.1.85",
3
+ "version": "0.1.87",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -661,6 +661,7 @@ function InputFieldRoot({
661
661
  <Popover
662
662
  open={true}
663
663
  trigger={rootElement}
664
+ initialFocus={false}
664
665
  sideOffset={sideOffset}
665
666
  showArrow={false}
666
667
  >
@@ -31,6 +31,9 @@ interface Props {
31
31
  style?: React.CSSProperties;
32
32
  portalContainer?: HTMLElement | null;
33
33
  side?: "top" | "bottom" | "left" | "right";
34
+ initialFocus?: React.ComponentProps<
35
+ typeof PopoverPrimitive.Popup
36
+ >["initialFocus"];
34
37
  /**
35
38
  * Called when an interaction outside the popover occurs.
36
39
  * Return false to prevent the popover from closing.
@@ -58,6 +61,7 @@ export function Popover({
58
61
  className,
59
62
  portalContainer,
60
63
  style,
64
+ initialFocus,
61
65
  shouldCloseOnInteractOutside,
62
66
  }: Props) {
63
67
  const defaultId = useId();
@@ -126,6 +130,7 @@ export function Popover({
126
130
  >
127
131
  <PopoverPrimitive.Popup
128
132
  ref={popupRef}
133
+ initialFocus={initialFocus}
129
134
  style={style}
130
135
  className={cx(
131
136
  popoverStyle.base,
@@ -0,0 +1,36 @@
1
+ import { act, cleanup, render } from "@testing-library/react";
2
+ import { afterEach, describe, expect, test } from "bun:test";
3
+ import React, { useEffect, useRef } from "react";
4
+ import { InputField } from "../InputField";
5
+
6
+ afterEach(cleanup);
7
+
8
+ describe("InputField", () => {
9
+ test("keeps focus on the input when its popover mounts", async () => {
10
+ let input: HTMLInputElement | null = null;
11
+
12
+ function InputWithPopover() {
13
+ const inputRef = useRef<HTMLInputElement>(null);
14
+
15
+ useEffect(() => {
16
+ requestAnimationFrame(() => inputRef.current?.focus());
17
+ }, []);
18
+
19
+ return (
20
+ <InputField
21
+ ref={(element) => {
22
+ inputRef.current = element;
23
+ input = element;
24
+ }}
25
+ width={240}
26
+ renderPopoverContent={() => <button>Result</button>}
27
+ />
28
+ );
29
+ }
30
+
31
+ render(<InputWithPopover />);
32
+ await act(() => new Promise((resolve) => setTimeout(resolve, 50)));
33
+
34
+ expect(document.activeElement === input).toBe(true);
35
+ });
36
+ });
@@ -209,19 +209,9 @@ export const DrawerWorkspaceLayout = memoGeneric(function DrawerWorkspaceLayout<
209
209
  {isDrawerOpen && (
210
210
  <div className="n-absolute n-inset-0 n-z-20 n-flex n-flex-col">
211
211
  {/* Drawer content */}
212
- <div className="n-flex-none n-max-h-[50vh] n-overflow-auto n-bg-sidebar-background n-border-b n-border-divider-strong n-shadow-lg">
212
+ <div className="n-relative n-flex-1 n-min-h-0 n-overflow-auto n-bg-sidebar-background n-border-b n-border-divider-strong n-shadow-lg">
213
213
  {activeDrawerPanel}
214
214
  </div>
215
- {/* Backdrop - click to close */}
216
- <div
217
- className="n-flex-1 n-bg-black/30"
218
- onClick={() =>
219
- setLayoutState({
220
- leftSidebarCollapsed: true,
221
- rightSidebarCollapsed: true,
222
- })
223
- }
224
- />
225
215
  </div>
226
216
  )}
227
217
 
@@ -31,4 +31,66 @@ describe("DrawerWorkspaceLayout", () => {
31
31
 
32
32
  expect(getByText("Sidebar content")).toBeTruthy();
33
33
  });
34
+
35
+ test("contains absolutely positioned panel content in a full-height drawer", () => {
36
+ const leftSidebarRef = React.createRef<SidebarRef>();
37
+ const rightSidebarRef = React.createRef<SidebarRef>();
38
+ const { getByRole, getByText, queryByRole } = render(
39
+ <DrawerWorkspaceLayout
40
+ leftPanel={<div className="n-absolute n-inset-0">Sidebar content</div>}
41
+ leftTabItems={[{ title: "Navigation", value: "navigation" }]}
42
+ leftTabValue="navigation"
43
+ rightPanel={null}
44
+ centerPanel={<div>Center content</div>}
45
+ leftSidebarOptions={{}}
46
+ rightSidebarOptions={{}}
47
+ leftSidebarRef={leftSidebarRef}
48
+ rightSidebarRef={rightSidebarRef}
49
+ compactDrawerMenu
50
+ />
51
+ );
52
+
53
+ fireEvent.click(getByRole("button", { name: "Navigation" }));
54
+
55
+ const drawerContent = getByText("Sidebar content").parentElement;
56
+ expect(drawerContent).toBeTruthy();
57
+ expect(drawerContent?.classList.contains("n-relative")).toBe(true);
58
+ expect(drawerContent?.classList.contains("n-flex-1")).toBe(true);
59
+ expect(drawerContent?.classList.contains("n-min-h-0")).toBe(true);
60
+ expect(drawerContent?.classList.contains("n-h-[50vh]")).toBe(false);
61
+ expect(queryByRole("button", { name: "Close drawer" })).toBeNull();
62
+ });
63
+
64
+ test("keeps touch input on drawer content instead of an overlapping backdrop", () => {
65
+ const leftSidebarRef = React.createRef<SidebarRef>();
66
+ const rightSidebarRef = React.createRef<SidebarRef>();
67
+ let touchCount = 0;
68
+ const { getByRole, getByText, queryByRole } = render(
69
+ <DrawerWorkspaceLayout
70
+ leftPanel={<button onClick={() => touchCount++}>Drawer action</button>}
71
+ leftTabItems={[{ title: "Navigation", value: "navigation" }]}
72
+ leftTabValue="navigation"
73
+ rightPanel={null}
74
+ centerPanel={<div>Center content</div>}
75
+ leftSidebarOptions={{}}
76
+ rightSidebarOptions={{}}
77
+ leftSidebarRef={leftSidebarRef}
78
+ rightSidebarRef={rightSidebarRef}
79
+ compactDrawerMenu
80
+ />
81
+ );
82
+
83
+ fireEvent.click(getByRole("button", { name: "Navigation" }));
84
+ const action = getByRole("button", { name: "Drawer action" });
85
+ const drawer = getByText("Drawer action").parentElement?.parentElement;
86
+
87
+ fireEvent.pointerDown(action, { pointerType: "touch" });
88
+ fireEvent.pointerUp(action, { pointerType: "touch" });
89
+ fireEvent.click(action);
90
+
91
+ expect(drawer?.classList.contains("n-z-20")).toBe(true);
92
+ expect(queryByRole("button", { name: "Close drawer" })).toBeNull();
93
+ expect(touchCount).toBe(1);
94
+ expect(leftSidebarRef.current?.isExpanded()).toBe(true);
95
+ });
34
96
  });