@estiva-app/ui 0.60.1 → 0.60.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.60.1",
3
+ "version": "0.60.2",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.60.1",
7
+ "packageVersion": "0.60.2",
8
8
  "exports": 134,
9
9
  "typeExports": 141,
10
10
  "files": null
@@ -54,7 +54,9 @@ function Root({ children }) {
54
54
  did, which is also what a story or a test sees without one.
55
55
  - `pictureFor` gets the person's name and returns an address, or nothing for
56
56
  the initials.
57
- - `navigate` gets the link's `href` exactly as written. The browser keeps
57
+ - `navigate` gets the link's path, query and `#` part (`/message/1?x=2`),
58
+ also when the `href` is the app's whole address (`https://app.test/message/1`):
59
+ a router reads a whole address as a path under the current page. The browser keeps
58
60
  every other click: one already handled (`preventDefault`), one with Ctrl,
59
61
  Cmd, Shift or Alt, the middle button, a link that opens a new tab or
60
62
  downloads, and an address on another site or in another scheme
@@ -86,6 +86,13 @@ describe('changing page', () => {
86
86
  expect(navigate).toHaveBeenCalledWith('/topics')
87
87
  })
88
88
 
89
+ it("hands over the path when the href is the app's whole address", async () => {
90
+ const navigate = vi.fn()
91
+ inApp(navigate, <Link href={`${window.location.origin}/message/1?thread=2#r3`}>Message</Link>)
92
+ await userEvent.click(screen.getByRole('link'))
93
+ expect(navigate).toHaveBeenCalledWith('/message/1?thread=2#r3')
94
+ })
95
+
89
96
  it("runs the caller's own onClick first", async () => {
90
97
  const order: string[] = []
91
98
  inApp(() => order.push('navigate'), <Link href="/topics" onClick={() => order.push('caller')}>Topics</Link>)
@@ -10,8 +10,9 @@ export interface AppProviderProps {
10
10
  pictureFor?: (name: string) => string | null | undefined
11
11
  /**
12
12
  * How this app changes page without reloading. A plain click on a link to
13
- * this app's own address calls it with the link's `href` instead of loading
14
- * the page again: `Link` (and so `Card` and `Breadcrumb`'s crumbs),
13
+ * this app's own address calls it with the link's path (`/message/1`, also
14
+ * when the `href` is the whole `https://…` address) instead of loading the
15
+ * page again: `Link` (and so `Card` and `Breadcrumb`'s crumbs),
15
16
  * `NavItem` (and so `NavTree`'s rows), `RailItem`, `Chip`, `InlineChip`, and
16
17
  * `IconButton` (and so `ToolbarLink`).
17
18
  */
@@ -71,6 +72,8 @@ export function useInAppClick<E extends HTMLElement>(href: string | undefined, o
71
72
  }
72
73
  if (url.origin !== window.location.origin) return
73
74
  event.preventDefault()
74
- navigate(href)
75
+ // The path, never the whole address: a router reads `https://…` as a path
76
+ // under the current page and lands nowhere (Peek's message link, 8 October).
77
+ navigate(`${url.pathname}${url.search}${url.hash}`)
75
78
  }
76
79
  }