Skip to content

fix(views): table view search, filters, selection and rows - #13885

Open
yuxi-liu-wired wants to merge 14 commits into
logseq:masterfrom
yuxi-liu-wired:fix/dbtest-1398
Open

yuxi-liu-wired wants to merge 14 commits into
logseq:masterfrom
yuxi-liu-wired:fix/dbtest-1398

Conversation

@yuxi-liu-wired

@yuxi-liu-wired yuxi-liu-wired commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Combines the PRs of this theme, to keep the number of open PRs down; the commits are unchanged. CI's unit suite passes on the combined branch.

fix(views): table view search, unresolved page refs and duplicated row buttons (was #13885)

Fixes logseq/db-test#1407, fixes logseq/db-test#1096; part of logseq/db-test#1266 (the duplicated buttons; the buttons missing in All Pages are not changed).

Three fixes for table views, one commit each. logseq/db-test#1398 (the search box disappears on the first keystroke) is fixed on master by #13590 (fe7660b); this PR's commit for it is dropped, and its review follow-up below is ported onto master's code. The table view issues #1100, #1123 and #1240 are not in this PR (see the end).

What the user sees

  • refactor: block insert && update #1407: in a table view of Linked References, a block that references a journal page shows [[]] is here instead of the page name. It happens after the journal date format was changed in Settings. The list view is fine.
  • 如何向Logseq(PC端)中导入MarkDown文件? #1266: hovering a row in a tag view table shows the "Open" and "Open in sidebar" buttons twice, once in the Page name column and once in a text property column such as Description.
  • Unpublishing a page corrupts page if you delete front matter #1096: in the All Pages table, selecting a page and then shift-clicking another page further down selects only those two pages. The delete confirmation lists just the first and the last page.
  • Review follow-up: in a view that is not windowed, such as Linked References, changing a filter or the sort left the old rows on screen, and selectable, until the new result arrived.

Cause

  • refactor: block insert && update #1407: a page reference without a label is rendered with an empty string as its label. When the page lookup misses, page-cp-inner falls back to (or label (:block/name page)). An empty string is truthy in ClojureScript, so the fallback printed the empty label between the brackets instead of the page name. Changing the journal date format makes the lookup miss, because the title text in the table row no longer matches the stored journal page name.
  • 如何向Logseq(PC端)中导入MarkDown文件? #1266: text property cells render through block-title, which draws the hover buttons for every cell. They were meant for the name column only.
  • Unpublishing a page corrupts page if you delete front matter #1096: the shift-click range was computed over the table's :data. In a windowed table such as All Pages, :data holds only the rows of the first window, while the whole ordered list is in :full-data. A clicked row below the window had index -1, so the range between the two clicks was empty. The e2e test showed Selected: 2 where 40 were expected.
  • Review follow-up: master's view-paint-identity (fix: keep table search mounted during view-data refetch #13590) is built from the window context, which is nil in a non-windowed view, so the identity never changes there and the old paint is kept.

Change

  • refactor: block insert && update #1407: the fallback in page-cp-inner uses the page name when the label is blank, the same blank check that page-inner already uses.
  • 如何向Logseq(PC端)中导入MarkDown文件? #1266: block-title-interactive draws the buttons only when :property-ident is :block/title (the name column). Click to edit and shift-click to open in the sidebar are unchanged. The report that the buttons are missing in the All Pages name column is not traced or changed here.
  • Unpublishing a page corrupts page if you delete front matter #1096: the range runs over :full-data for a flat table and over the group for a group table (table-range-rows, table-row-index, select-table-row-range!). A clicked row that is not in the list no longer cancels the click, so it toggles like a normal click. The gallery card checkbox uses the same helpers.
  • Review follow-up: view-paint-identity takes the resource plan and falls back to the full context when there is no window context, still without the search input.

Tests

  • paint-identity-changes-with-sort-and-filter-of-a-non-windowed-view-test (views_1398_test.cljs): for a Linked References plan the paint identity is the same for different search inputs and changes for a different sort or filter.
  • unresolved-page-reference-shows-its-name-test (block/page_reference_test.cljs): page-cp-inner for a page that only has a name shows the name for a nil or empty label and the label when there is one.
  • open-buttons-render-only-in-the-name-column-test (views_test.cljs): the name column cell has two buttons, a text property cell has none.
  • shift-click-selects-the-range-past-the-painted-window-test (views_test.cljs): shift-clicking a row past the painted window selects every row between the two clicks, for a flat table and for a group table.
  • all-pages-shift-click-selects-the-range-past-the-first-window-test (clj-e2e/test/logseq/e2e/view_basic_test.clj): creates 45 pages, selects the first row, scrolls and shift-clicks the checkbox of a page below the first window, then checks the selection count and the pages listed in the delete confirmation. It fails on a build without the fix (Selected: 2) and passes on a build with it.

Each unit test fails without its fix and passes with it, and the whole CI suite passes with each fix (the last suite run had one db-worker-node worker fail under load, and the same namespaces passed when rerun alone).

Not in this PR

fix(views): table filters keep working when a clause is empty or matches text values (was #13884)

Fixes logseq/db-test#1434, fixes logseq/db-test#1392, fixes logseq/db-test#1054.

Three table view filter bugs, one commit each.

What the user sees

  • Click the Advanced Queries block and don't jump to the target.  #1434: On All Pages, a Tags filter set to "Empty" crashes the page with "Invalid view resource context" as soon as the operator is switched between "is" and "is not". The broken filter is saved on the view, so the page keeps failing until the filter is removed.
  • 无法保存文件 #1392: Changing a Text filter from "is" to "text contains" (or "text not contains") replaces the table with "Invalid view resource context" before a search string can be typed. The error stays after a reload.
  • feat: upgrade some dependencies #1054: In a query table, a grouped table or a linked-references table, a filter such as "Author is Smith" on a text property shows only one of the blocks whose Author is Smith. The same filter in a tag's table, or with the clause added a second time, shows all of them.

Cause

  • Click the Advanced Queries block and don't jump to the target.  #1434: When the operator changes, view-filter-value-after-operator-change (src/main/frontend/worker/handler/view.cljs) kept the value for :is and :is-not only when it was a set. The Empty choice is stored as the keyword :empty, so it was dropped and the two-element clause [:block/tags :is] was saved.
  • 无法保存文件 #1392: A clause without a value is the normal state of a filter whose value has not been entered yet: changing the operator clears the old values, persistence drops a nil value on purpose (table-filters->persist-state), the editor creates [property :text-contains] for a new Text filter, and both filter matchers (row-matched? and eid-clause-match?) treat a clause without a value as matching every row. Only valid-filters? in src/main/frontend/worker/handler/render_resource/view.cljs required exactly three elements, so it rejected a clause the rest of the code accepts. The clause is therefore valid and the validation was wrong, and the code that builds clauses is unchanged. Click the Advanced Queries block and don't jump to the target.  #1434 is a separate bug in which a value that should have been kept was lost, so it is fixed where the clause is built.
  • feat: upgrade some dependencies #1054: Every block stores its text in its own value block, and the filter's value list keeps one entry per distinct text. For a single :is or :is-not clause on a ref property, build-fast-filter-pred (deps/db/src/logseq/db/common/view.cljs) compared value block ids, so only the block whose value block was listed matched. row-matched? compares the text for such values, which is why a second clause gave the expected rows. Properties with choices share one value block per choice and were not affected.

Change

  • Click the Advanced Queries block and don't jump to the target.  #1434: view-filter-value-after-operator-change also keeps :empty for :is and :is-not.
  • 无法保存文件 #1392: valid-filters? accepts clauses with two or three elements. A clause of any other length is still rejected, and the worker already reports that as the view's error message (isolated-view-failure) instead of failing the whole snapshot. Views that already have such a clause saved render again without being edited.
  • feat: upgrade some dependencies #1054: build-fast-filter-pred makes the same choice as row-matched?: a value that is not matched as an entity (match-property-value-as-entity?) is compared by its content instead of its id.

Tests

  • Click the Advanced Queries block and don't jump to the target.  #1434: view-filter-data-keeps-empty-value-when-switching-is-and-is-not (src/test/frontend/worker/handler/view_test.cljs). Fails without the fix (2 failures), passes with it.
  • 无法保存文件 #1392: view-data-resource-accepts-filter-clauses-without-a-value-test (src/test/frontend/worker/handler/render_resource_test.cljs). Requests a view with two valueless clauses and expects no error and the clauses passed to the view query; also checks that clauses with one or four elements are still an isolated view error. Fails without the fix (2 failures in render-resource-test, 95 tests), passes with it, and the whole main-bundle suite passes.
  • feat: upgrade some dependencies #1054: get-view-data-query-result-is-filter-matches-equal-text-in-separate-value-blocks-test (deps/db/test/logseq/db/common/view_test.cljs). Filters a query table on the text of one of two blocks with the same text. Without the fix :is returns one of the two blocks and :is-not returns the other matching block (2 failures); with it :is returns both and :is-not returns only the block with different text. The whole deps/db suite passes (201 tests, 766 assertions).

Devin Review

Added: issues from the second triage pass and the view filter fuzzer

Fixes logseq/db-test#1413, Fixes logseq/db-test#1303, Fixes logseq/db-test#1228, Fixes logseq/db-test#1443.

One commit per issue, each with its test, plus two commits for bugs of the same classes that a view filter fuzzer (random filter edits as the UI makes them, checked against the worker's view-data resource and an independent row matcher) found. With this PR the fuzzer goes from 9 distinct failures on master to 1 (the cleared text filter below, which needs a decision). #1443 (changing the operator of a datetime filter gives "Invalid view resource context") is fixed in two parts: the resource accepting a clause with no value (commit 252b566 above, test view-data-resource-accepts-filter-clauses-without-a-value-test) and the operator menu no longer throwing on such a clause (the second fuzzer section below).

Found by the view filter fuzzer (same classes)

match any with no clauses hides every row (class of #1413 and #1443: states the UI can produce)

What the user sees: in a query table, a list view or a grouped table, removing the last filter while "Match any" is set shows no rows. The flat table shows all of them.

Cause: get-view-data goes through row-matched? for views that are not flat tables, and it enters that path when the filters map is non-empty, which {:or? true :filters []} is. row-matched? ran some over no clauses, which is nil. The id path for flat tables already treats no clauses as match-all.

Change: row-matched? matches every row when there are no clauses. The search input still applies.

Test: get-view-data-query-result-match-any-without-clauses-keeps-every-row-test (deps/db, nbb). On master it returns no rows.

Changing the operator of a filter that has no value does nothing (class of #1443)

What the user sees: a new Name filter, or a cleared number or range, cannot get another operator: the menu item throws and nothing shows.

Cause: the operator menu read the old value with (nth clause 2), but a clause with no value is [property operator] (the number and range inputs and table-filters->persist-state produce them on purpose).

Change: the operator change moves into <change-filter-operator!, which reads the old value with (nth clause 2 nil).

Test: change-filter-operator-of-a-filter-without-value-test. On the old expression it fails with "No item 2 in vector of length 2".

Left to other PRs or a decision

  • Any clause with no value is rejected by the view-data resource (fuzzer bug 1) and a single is/is-not on a text, number or url property compares value-entity identity on the entity path (bug 5): both are fixed by the earlier commits of this PR (252b5662ed, 0aca17fe60); the fuzzer finds neither.
  • A cleared text filter value ([:p :text-contains ""]) restricts the rows to those that have a value, while a cleared number input stores a clause with no value (fuzzer bug 7). Either the text input stores [p op] for a blank input, or the db view treats a blank match as no restriction. This needs a decision, not changed here.

#1413: the filter menu of a query table lists only Todo for Status

What the user sees: in the table of a query result (for example #task), the Filter menu of the Status property offers only Todo, whatever values the rows have.

Cause: the filter menu asked the worker for the values of the rows with :query-entity-ids, an option that the data-fetch refactor (fb1047d) replaced with :query-row-uuids in the view, so it was always nil. get-property-values then fell back to the entities of the view, which a query-result view does not have, and added only the default value of the property (Todo).

Change: the filter menu passes :query-row-uuids, and view-filter-data in the worker resolves them to the entity ids that get-property-values reads, as the view resource does.

Test: view-filter-data-lists-the-values-of-the-query-result-rows (two of three tagged blocks are rows of the query; only their values are listed). On master it returns no values.

Not checked at runtime: the Name filter that the issue says is missing is not explained by the code (filterable-column? keeps :block/title), so I did not change it; it should be looked at in the UI with this fix.

#1303: a user-added closed value has no icon in its group header and sorts to one end

What the user sees: in a table view grouped by Status, a Status value the user added shows its emoji in the rows, but its group header has no icon, and its group is first or last instead of at its place in the value dropdown.

Cause: get-view-data keeps a closed value as an entity group key only if match-property-value-as-entity? says so, and for a text property that is true only for values with a :db/ident (the built-in ones). A value the user added has no ident, so the group key became its text. The group sort reads :block/order of the key and the header reads :logseq.property/icon of it; a string has neither.

Change: when the grouped property has closed values, get-view-data keeps the closed value entity as the group key whether or not it has an ident.

Test: get-view-data-group-by-user-added-closed-value-keeps-the-value-entity-test (a property whose dropdown order is Charlie, Alpha, Bravo, with an icon on Alpha; ascending, descending and the icon of the group key). It is in the main test bundle (src/test/logseq/db/common/view_group_test.cljs) because nbb does not support the :property/closed-values lookup. On master the group keys are strings.

#1228: the name cell of a page without a title is empty

What the user sees: in the All Pages table, a page whose title is blank or only its uuid has an empty name cell, with only the hover arrow, so it cannot be recognised.

Cause: the name cell printed the first line of the title with no fallback. Page references (page-reference), the left sidebar and the route title already show Untitled for such pages.

Change: the name cell, in both the first-window paint and the full cell, shows Untitled when the first line of the title is blank or a uuid. Any row whose title is blank gets it, not only pages.

Test: table-name-cell-shows-untitled-for-a-page-without-title-test (blank, whitespace, missing and uuid titles in both cells, and a normal title unchanged). On master the cells are empty or show the uuid.

Not changed: "select and delete does nothing" is logseq/db-test#1207. How the untitled pages were created is still unknown.

Validation

Run with the heavy build: the new tests fail on master and pass with the fixes (the 1303 and 1413 tests fail on a master build, the 1228 test on a build with the first two fixes, which do not touch its code, the operator test on the old nth, the match-any test in nbb without the fix). The view filter fuzzer (100 seeds x 12 steps, FUZZ view-filter cases=100 steps=12 seed=1): on master 9 distinct failures (failures counts per invariant: resource-rejects-ui-state 367, ui-throws 22, filter-rows 53, filter-values 33, group-closed 11); on this branch alone failures=4 (resource-rejects-ui-state, and filter-rows for bug 5 and bug 7); on this branch with the two #13885 commits applied failures=1 (bug 7 only). The fuzzer's ui-view-args and operator-menu mirror were updated to the fixed UI code. CI's whole unit suite (pnpm cljs:run-test) passes on the branch, clj-kondo reports 0 errors and 0 warnings on the changed files, and the typos check is clean.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Devin Review

Comment thread src/main/frontend/components/views.cljs Outdated
;; Identifies the view whose previous paint may stay on screen while the
;; next result loads. The search input is left out: typing must keep the
;; old table mounted so the search box is not unmounted mid-keystroke.
:previous-paint-key (pr-str (dissoc window-context :input))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Old results survive non-windowed filter changes

Changing filters or sorting in non-windowed views leaves previous-view-data visible while the new result loads. Their window-context is nil, so previous-paint-key never changes and the old rows remain selectable under the new settings.

Learn more

A non-windowed view fetches its rows with full-context, while window-context remains nil. Its resource key changes on sorting, filtering, or query row changes, but its previous-paint key stays constant. The paint source then continues to use the previous rows until the new resource arrives. This leaves old rows interactive under changed controls.

Example: In Linked References, apply a filter that excludes every row. Until the new resource loads, the previous rows remain visible and selectable beneath the active filter.

Recommended fix: Derive previous-paint-key from (or window-context full-context), excluding only :input. Add a non-windowed view plan test verifying that filter and sort changes alter this key.

Suggested change
:previous-paint-key (pr-str (dissoc window-context :input))
:previous-paint-key (pr-str (dissoc (or window-context full-context) :input))

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread src/main/frontend/components/views.cljs Outdated
Comment on lines +4097 to +4102
;; Keep previous paint for same-context refetches (delete) and for
;; search input changes, so the search box stays mounted while typing.
;; A new filter/sort key must not keep the old 431-row table.
(set-previous-view-data! nil)
js/undefined)
[(:previous-paint-key plan)])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Search retains interactive old rows

While a new search loads, the previous rows remain interactive beneath the new search text. Consider a loading indicator to distinguish pending results from matches.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +1 to +7
(ns frontend.components.block.page-reference-test
(:require ["react" :as react]
["react-dom/server" :as react-dom-server]
[cljs.test :refer [deftest is testing]]
[clojure.string :as string]
[frontend.components.block :as block]
[goog.object :as gobj]))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Single-test namespace adds maintenance overhead

The new reference test occupies a separate namespace for one case. Check whether the existing block test suite offers a simpler home.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@yuxi-liu-wired

Copy link
Copy Markdown
Contributor Author

Thanks for the review.

  1. :previous-paint-key in the resource plan was built from window-context only, and a non-windowed view (Linked References and the like) has no window context, so the key never changed there. It now falls back to the full context ((or window-context full-context)), still without the search input, so typing keeps the table mounted. Fixed in 204fb22. The new test previous-paint-key-changes-with-sort-and-filter-of-a-non-windowed-view-test builds the plan for a non-windowed view and checks that the key is the same for different search inputs and differs for a different sort or filter. It fails without the change and passes with it.

  2. Old rows being interactive while a new search loads is how master already behaves while any view resource loads: the previous paint stays until the new data arrives. This PR does not change that for a search, because keeping the table mounted is what keeps the search box open. A new sort, filter or grouping still drops the old rows.

  3. frontend.components.block.page-reference-test has one test. I am keeping it as its own namespace. block.cljs has no test namespace of its own, and the other files in src/test/frontend/components/block/ each cover one concern in the same way (video_test, macros_test, url_property_test), so a new block_test would be a catch-all. More page reference cases can be added to this file.

@yuxi-liu-wired yuxi-liu-wired changed the title fix(views): table view search, unresolved page refs and duplicated row buttons fix(views): table view search, filters, selection and rows Oct 28, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 28, 2026
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 29, 2026
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 29, 2026
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
yuxi-liu-wired pushed a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 30, 2026
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 30, 2026
…ws (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 31, 2026
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Oct 31, 2026
…ws (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 1, 2026
…ws (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 2, 2026
…ws (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 3, 2026
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 3, 2026
…ws (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 4, 2026
…ws (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 17, 2026
…ws (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
@yuxi-liu-wired
yuxi-liu-wired force-pushed the fix/dbtest-1398 branch 2 times, most recently from 04d04c0 to 53066e9 Compare November 18, 2026 14:35
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…ws (squashed: its commits conflicted one by one with the stack)
yuxi-liu-wired added a commit to yuxi-liu-wired/logseq that referenced this pull request Nov 18, 2026
…ws (squashed: its commits conflicted one by one with the stack)
A table view's name column, such as Linked References as a table, showed `[[]] is here` for a block that references a journal page. The same view as a list showed the page link. It happened after the journal date format was changed in Settings.

A reference without a label is rendered with an empty string as its label. When the page lookup misses, `page-cp-inner` falls back to `(or label (:block/name page))`. An empty string is truthy in ClojureScript, so the fallback printed the empty label between the brackets instead of the page name. Changing the journal date format makes the lookup miss, because the title text in the table row no longer matches the stored journal page name.

The fallback now uses the page name when the label is blank, the same blank check that `page-inner` already uses for the label.

The new test renders `page-cp-inner` for a page that only has a name, with a nil, an empty and a real label.

Fixes logseq/db-test#1407
Hovering a row in a tag view table showed the "Open" and "Open in sidebar" buttons twice: once in the Page name column and once in a text property column such as Description.

Text property cells render through `block-title`, which draws the hover buttons for any cell. The buttons were meant for the name column only, so every text column repeated them.

`block-title-interactive` now draws the buttons only when the cell is the name column (`:property-ident` is `:block/title`). Clicking the cell to edit it and shift-click to open it in the sidebar are unchanged.

The new test renders the cell for the name column and for a text property and counts the buttons. This does not cover the buttons that reportedly do not appear in the All Pages name column; that part of the issue is not changed here.

Refs logseq/db-test#1266
…filter or sort

In views that are not windowed, such as Linked References, changing a filter or the sort order left the old rows on screen, and selectable, until the new result arrived.

The previous paint is reset when `:previous-paint-key` changes. The key was built from the window context only, and a non-windowed view has no window context, so the key never changed there.

The key now falls back to the full context when there is no window context. The search input is still left out of it, so typing keeps the table mounted.

The new test builds the resource plan for a non-windowed view and checks that the key stays the same for a different search input and changes for a different sort order or filter.
In the All Pages table, selecting a page, then shift-clicking the checkbox of another page far enough down selected only those two pages. The delete confirmation listed just the first and the last page.

A shift-click range was computed over the table's `:data`. In a windowed table such as All Pages, `:data` holds only the rows of the first window, while the whole ordered list is in `:full-data`. The second page was not in the window, so its index was -1 and the range between the two clicks was empty.

The range now runs over `:full-data` for a flat table, and over the group for a group table. A clicked row that is not in the list no longer cancels the click, so it toggles like a normal click. The gallery card checkbox shares the same helpers.

The new unit test shift-clicks a row past the painted window and checks that every row between the two clicks is selected, for a flat table and for a group table. The e2e test creates 45 pages, selects the first, shift-clicks the checkbox of a page below the first window, and checks the selection count and the pages listed in the delete confirmation.

Fixes logseq/db-test#1096
…d is not

On a table view such as All Pages, a filter set to "Tags is Empty" crashed the page with "Invalid view resource context" as soon as the operator was switched between "is" and "is not". The broken filter was saved on the view, so the page kept crashing until the filter was removed.

When the operator changes, the worker decides which value the filter keeps. For "is" and "is not" it kept the value only if it was a set, but the Empty choice is stored as the keyword :empty, so it was dropped. The UI then saved a two-element clause such as [:block/tags :is], which view resource validation rejects.

view-filter-value-after-operator-change now also keeps :empty for "is" and "is not". The views.cljs call site already passes the current value and stores what the worker returns, so it needs no change.

Added view-filter-data-keeps-empty-value-when-switching-is-and-is-not, which checks that :empty survives a switch to :is and :is-not and is still dropped for an operator that cannot use it (:text-contains).

Fixes logseq/db-test#1434
…th a single is clause

In a query table, a grouped table or a linked-references table, a filter such as "Author is Smith" on a text property showed only one of the blocks whose Author is Smith. The same filter in a tag's table, or with the clause added a second time, showed all of them.

Every block stores its text in its own value block, and the filter's value list keeps one entry per distinct text. For a single is or is-not clause on a ref property, build-fast-filter-pred compared the ids of the value blocks, so only the block whose value block was listed matched. row-matched? compares the text in this case, which is why a second clause gave the expected rows. Properties with choices share one value block per choice and were not affected.

build-fast-filter-pred now makes the same choice as row-matched?: a value that is not matched as an entity is compared by its content instead of its id.

Added get-view-data-query-result-is-filter-matches-equal-text-in-separate-value-blocks-test, which filters a query table on the text of one of two blocks that have the same text and expects both, and the other block for is-not.

Fixes logseq/db-test#1054
On a table view, changing a Text filter from "is" to "text contains" (or "text not contains") replaced the table with "Invalid view resource context" before a search string could be typed. The incomplete clause was saved on the view, so the error stayed after a reload.

When the operator changes, the old selected values are cleared and the clause is saved as [property operator], and the filter editor produces the same two-element clause for a newly added Text filter. Persistence also drops a nil value on purpose, and both filter matchers treat a clause without a value as matching every row. Only the view resource context validation required exactly three elements, so it rejected a clause the rest of the code accepts.

The validation now accepts clauses with two or three elements. A clause of any other length is still rejected and is reported as the view's error message instead of failing the whole snapshot. Views that already have such a clause saved render again without being edited.

Added view-data-resource-accepts-filter-clauses-without-a-value-test, which requests a view with two valueless clauses and expects no error and the clauses passed to the view query, and checks that clauses with one or four elements are still reported as an isolated view error.

Fixes logseq/db-test#1392
… with its icon

In a table view grouped by a property with closed values (such as Status), a value the user added themselves showed no icon in the group header and sorted to one end of the list instead of at its place in the value dropdown. The values that ship with Logseq were fine.

Cause: `get-view-data` keeps a closed value as an entity group key only if `match-property-value-as-entity?` says so, and that is true only for values with a `:db/ident` (the built-in ones) when the property is of a text type. A value the user added has no ident, so the group key became its text. The group sort reads `:block/order` of the key and the header reads `:logseq.property/icon` of it; a string has neither, so the group sorted lowest and had no icon.

Change: when the grouped property has closed values, `get-view-data` keeps the closed value entity as the group key whether or not it has an ident.

Test: `get-view-data-group-by-user-added-closed-value-keeps-the-value-entity-test` groups by a property whose dropdown order differs from the alphabetical one and whose second value has an icon. It runs in the main test bundle because nbb does not support the `:property/closed-values` lookup.

Fixes logseq/db-test#1303
… query table

In the table of a query result, the Filter menu of a property such as Status offered only `Todo`, whatever values the query rows had.

Cause: the filter menu asked the worker for the values of the rows with `:query-entity-ids`, an option that the data-fetch refactor (fb1047d) replaced with `:query-row-uuids` in the view, so it was always nil. `get-property-values` then fell back to the entities of the view, which a query-result view does not have, and added only the default value of the property.

Change: the filter menu passes `:query-row-uuids`, and `view-filter-data` in the worker resolves them to the entity ids that `get-property-values` reads, as the view resource does.

Test: `view-filter-data-lists-the-values-of-the-query-result-rows` asks for the values of a property for two of three tagged blocks and expects only their values.

Fixes logseq/db-test#1413
In the All Pages table, a page whose title is blank or only its uuid had an empty name cell. The row could not be recognised, and the only thing left in it was the hover arrow.

Cause: the name cell printed the title text of the row with no fallback. Page references, the left sidebar and the route title already show `Untitled` for such pages.

Change: the name cell, in both the first-window paint and the full cell, shows `Untitled` when the first line of the title is blank or a uuid.

Test: `table-name-cell-shows-untitled-for-a-page-without-title-test` renders the name cell and the first-window name cell for a blank, a whitespace, a missing and a uuid title, and for a normal title.

Fixes logseq/db-test#1228
…atch any" is set

In a query table, a list view or a grouped table, removing the last filter while "Match any" was set made every row disappear. The same view as a flat table showed all rows.

Cause: `get-view-data` filters through `row-matched?` when the view is not a flat table, and it enters that path when the filters map is not empty, which `{:or? true :filters []}` is. `row-matched?` then ran `some` over no clauses, which is nil, so no row matched. The id path for flat tables already treats no clauses as match-all.

Change: `row-matched?` matches every row when there are no clauses, whatever `:or?` is. The search input still applies.

Test: `get-view-data-query-result-match-any-without-clauses-keeps-every-row-test` (no clauses with `:or?` true and false, with and without a search input). Found by the view filter fuzzer.
…value

Choosing another operator for a filter that has no value yet (a new Name filter, or a cleared number or range) did nothing: the menu item threw and no error showed.

Cause: the operator menu read the old value with `(nth clause 2)`, but a clause with no value is `[property operator]`, which has two elements. Those clauses are legal: the number and range inputs and `table-filters->persist-state` produce them on purpose.

Change: the operator change moves into `<change-filter-operator!` and reads the old value with `(nth clause 2 nil)`.

Test: `change-filter-operator-of-a-filter-without-value-test` (on master's code it fails with "No item 2 in vector of length 2"). Found by the view filter fuzzer. This is the second half of the class of logseq/db-test#1443; the worker side (`valid-filters?` rejecting two-element clauses) is in logseq#13885.
… merges cleanly with logseq#13872

The tests this PR added to views_test.cljs sat at the same place as the ones logseq#13872 adds there, so the two PRs conflicted and the nightly merge left one of them out. The tests are unchanged; they now live in frontend.components.views-1398-test, which carries the requires and the render-static helper they need, and views_test.cljs is back to master's.
Master's 274eae1 derives a built class's ident from its title, so
:user.class/Topic no longer names the class the test builds and the test
created its view for no class.

This branch has not been deployed

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