Close the space menu when the space you pick has a page behind it
This commit is contained in:
parent
6e5b0dfd01
commit
a6b47bdb8b
3 changed files with 19 additions and 3 deletions
|
|
@ -173,7 +173,10 @@ test("takes over the space menu's history entry when you navigate out of it", as
|
|||
await expect(drawer).toHaveCount(0)
|
||||
})
|
||||
|
||||
test("switches spaces inside the space menu without closing it", async ({seed, as}) => {
|
||||
test("switches spaces inside the space menu, and out of one it has a page for", async ({
|
||||
seed,
|
||||
as,
|
||||
}) => {
|
||||
const scenario = await seed(({relay, user}) => {
|
||||
const space = relay("space")
|
||||
const other = relay("other")
|
||||
|
|
@ -207,6 +210,14 @@ test("switches spaces inside the space menu without closing it", async ({seed, a
|
|||
|
||||
await expect(page).toHaveURL(new RegExp(`${roomPath(other.url, "garden")}$`))
|
||||
await expect(drawer).toHaveCount(0)
|
||||
|
||||
// The space she started in has a page behind it now, so picking it needs no second tap and the
|
||||
// menu has nothing left to ask.
|
||||
await page.getByRole("button", {name: "Open space menu"}).click()
|
||||
await drawer.locator('.primary-nav [data-tip^="space"]').click()
|
||||
|
||||
await expect(page).toHaveURL(new RegExp(`${roomPath(space.url, "lounge")}$`))
|
||||
await expect(drawer).toHaveCount(0)
|
||||
})
|
||||
|
||||
test("enters a space on its details page whatever its relay advertises", async ({seed, as}) => {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
import RelayIcon from "@app/components/RelayIcon.svelte"
|
||||
import {relays} from "@app/core"
|
||||
import {navigate} from "@app/modal"
|
||||
import {makeSpacePath, makeSpaceEntryPath} from "@app/routes"
|
||||
import {makeSpacePath, makeSpaceEntryPath, hasSpacePage} from "@app/routes"
|
||||
import {notifications} from "@app/notifications"
|
||||
|
||||
type Props = {
|
||||
|
|
@ -17,7 +17,10 @@
|
|||
const onClick = () => {
|
||||
const entryPath = makeSpaceEntryPath(url)
|
||||
|
||||
navigate(entryPath, {keepModal: true, replaceState: entryPath === $page.url.pathname})
|
||||
navigate(entryPath, {
|
||||
keepModal: !hasSpacePage(url),
|
||||
replaceState: entryPath === $page.url.pathname,
|
||||
})
|
||||
}
|
||||
|
||||
const path = makeSpacePath(url)
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ export const makeSpacePath = (url: string, ...extra: (string | undefined)[]) =>
|
|||
|
||||
export const forgetSpacePage = (url: string) => lastPageBySpaceUrl.delete(url)
|
||||
|
||||
export const hasSpacePage = (url: string) => lastPageBySpaceUrl.has(url)
|
||||
|
||||
export const makeSpaceEntryPath = (url: string) =>
|
||||
lastPageBySpaceUrl.get(url) ?? makeSpacePath(url, "about")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue