Skip to content

Creating a page opens a nested page, a tag or a property with that name instead #1345

Open

Description

@yuxi-liu-wired

Steps

  1. Press Cmd+K (Ctrl+K), type "Foo/Bar", and create the page (the Library now holds Foo, with Bar under it).
  2. In a block on another page, type [[Bar and pick "New page Bar" in the popup.

Expected

A new top-level page "Bar", beside Foo/Bar's Bar. That is what the other order gives: create "Bar" first and "Foo/Bar" second, and both pages exist (the behavior db-test#429 asked for and 063aec02a gave).

Actual

No page is created, and the link points to Foo/Bar's Bar. Cmd+K offers no "Create page" item for "Bar" while Foo/Bar exists. The only way to a top-level "Bar" beside "Foo/Bar" is to create "Bar" first.

The same lookup opens a tag or a property that has the name: after creating the tag "#Foo", no route of the UI creates a page "foo" (Cmd+K and the [[ popup offer no create item, and <create! returns the tag), while creating the page "foo" first and the tag "#Foo" second gives both, and renaming another page to "foo" is accepted. A page, a tag and a property may share a name (the maintainer in db-test#350).

Tags have the same order dependence through the worker: after the tag "#Foo/Baz", creating the tag "#Baz" returns Foo/Baz's Baz, while "#Baz" first and "#Foo/Baz" second gives 2 tags named Baz (tags in different namespaces may share a name, db-test#466).

Cause

The popup offers "New page" when the page it found has a parent (matched-pages-with-new-page, src/main/frontend/components/editor.cljs), and its handler calls <create!. <create! (src/main/frontend/handler/common/page.cljs:139-147) pulls [:block/name (page-name-sanity-lc title)] first and returns the page it finds instead of creating one. :thread-api/pull resolves that lookup with ldb/get-page (src/main/frontend/worker/handler/query.cljs:39-47), the oldest page with that name, of any kind and any parent (get-first-page-by-name, deps/db/src/logseq/db/common/initial_data.cljs:17-21). The worker's own create would create the page: it looks for an existing page of the requested type only (ldb/page-exists? with #{:logseq.class/Page}) and creates a new page when the one it finds has a parent (deps/outliner/src/logseq/outliner/page.cljs:406-426).

For a tag, create itself asks ldb/page-exists? with #{:logseq.class/Tag}, which matches the exact title among all tags, whatever they extend (deps/db/src/logseq/db.cljs:516-534), and returns the tag it finds.

The renderer lookup came with a0b109399 ("fix: ui keep refresh with custom journal format", 2026-03-04), after db-test#429 was fixed by 063aec02a (2025-08-25). 3afb112b8 (db-test#563) later hid Cmd+K's create item whenever a page of that name exists, nested or not.

Found by the page model property test (frontend.worker.page-model-property-test, branch test/page-model-fuzz) on upstream master 16c4ed1a0: a post-condition of its create step (the create opened a namespace child or a page of another kind), and its check that "create X" and "rename Y to X" are accepted alike. Shortest sequences: FUZZ_REPLAY='[[:create 5 0 0] [:create 3 0 0]]' (create Foo/Bar, then Bar) and FUZZ_REPLAY='[[:create-tag 0 0 0] [:create 1 0 0]]' (the tag Foo, then the page foo), FUZZ_REPLAY='[[:tag-new 0 9 0] [:create-tag 38 0 0]]' (the tag Foo/Baz, then the tag Baz). The steps above use the [[ popup; the test calls <create!'s logic directly.

Activity

  1. yuxi-liu-wired commented on Oct 6, 2026

    @yuxi-liu-wired
    Author

    Fix for the page side: logseq/logseq#13625. A tag created with the name of a namespaced tag is not covered there.

  2. yuxi-liu-wired commented on Oct 6, 2026

    @yuxi-liu-wired
    Author

    Fix for the tag side: logseq/logseq#13626.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions