Repository navigation
fix(editor): collapse arrow, ordered-list Backspace, date picker Enter and selection bar actions - #13890
fix(editor): collapse arrow, ordered-list Backspace, date picker Enter and selection bar actions#13890yuxi-liu-wired wants to merge 6 commits into
Conversation
…l hidden A block whose only properties were hidden ones, or class properties that are empty and hidden, still showed the expand/collapse arrow. Expanding it revealed nothing. `db-collapsable?` counted every property key on the block, but the properties area renders only the rows in the block's display properties (`:full-properties`); hidden properties are left out and empty class properties can be hidden too. When the block carries `:block.temp/display-properties`, `db-collapsable?` now counts only the visible `:full-properties` rows. Blocks without it keep the old key-based check, and query blocks stay collapsable. The test checks that a block with only hidden rows is not collapsable, that one visible row makes it collapsable, and that a query block with no rows is still collapsable. Fixes logseq/db-test#1189
In an ordered list, Backspace at the start of an empty block turned the numbered item back into a bullet, but every further Backspace did the same and the block could not be deleted until the editor lost focus. `delete-block-when-zero-pos!` read the list type from the block returned by `state/get-edit-block`, which is captured when editing starts and still has `:logseq.property/order-list-type` after the first Backspace removed it. The list type is now read from `latest-renderer-block`, the same way `save-current-block!` reads the current block. The test runs Backspace on an empty numbered block twice: the first removes the list type, and the second, when the renderer's block no longer has the list type but the edit block still does, deletes the block. Fixes logseq/db-test#1417
…ning day In the property date picker (the `/deadline` and `/scheduled` commands and date properties), choosing a day with the arrow keys and pressing Enter saved today's date, or the old value, instead of the chosen day. The date was sometimes set and then reverted. Enter on a calendar day ran the day's own key handler, which selects that day, and then the picker's window keydown handler, which selected `initial-day`, the day the picker opened on. The later call overwrote the first. The window handler (now `confirm-initial-day-on-enter!`) no longer selects the opening day when the Enter comes from a calendar day. It still stops the event, and it still confirms the opening day when the focus is elsewhere in the picker. The test calls the handler with Enter on a calendar day (nothing selected), elsewhere in the picker (opening day selected) and in a form control (nothing selected). The picker for datetime properties (Deadline, Scheduled) still stays open after a day is chosen, so the time can be set; that is unchanged. Fixes logseq/db-test#1041
… selection With the floating selection toolbar open, extending the selection with Shift+Down and then using Tags tagged only the blocks that were selected when the toolbar appeared. Shrinking the selection tagged blocks that were no longer selected. The toolbar loads the selected blocks once, for the ids read at render, and stays mounted while the selection changes. The Tags, Set property and Unset property buttons passed those blocks to the dialog, and the dialog prefers passed blocks over the live selection. The three buttons now pass blocks only when the caller supplied its own selection (a table or query view). For the outliner selection they pass none, so the dialog reads the selection when it opens. The test checks that the outliner selection is left to the dialog and that a caller-supplied selection is passed on. Fixes logseq/db-test#1391
…utton on click Clicking the trash button in the selection toolbar (for example on the Pages table) showed the delete confirmation only while the mouse button was held; releasing it closed the dialog, so the selection could not be deleted. The button ran the delete on `:on-pointer-down`, which opens the confirmation. The pointer-up that ends the same press then counted as an outside click and closed it. The delete now runs on click. The pointer-down is still stopped, as for the other toolbar buttons, so the press does not clear the selection. The test checks that the pointer-down alone does not delete or open anything and that the click deletes the selection and hides the action bar. Fixes logseq/db-test#1207
| property-keys (if display-properties | ||
| (map :property-id (:full-properties display-properties)) |
There was a problem hiding this comment.
🟡 Hidden properties lose their expand control
When hidden properties are shown on a block with no visible rows, db-collapsable? removes its expand control. properties-area renders those hidden rows only while expanded, so collapsing hides them without a way to reopen.
Learn more
The block's render snapshot lists normally visible rows in :full-properties and hidden rows in :hidden-properties. properties-area separately tracks whether hidden properties are currently shown and renders their rows when enabled; block-content mounts that area only when the block is expanded. The new collapsibility check does not account for that visibility state, so it removes the arrow even when expansion reveals hidden rows.
Example: Give a block one property marked hidden, turn on its hidden-property display, then collapse the block. Its hidden row disappears and the expand arrow is absent, although expanding must reveal the row.
Recommended fix: Make the collapsibility calculation include currently displayed hidden rows, using the same per-block visibility state as properties-area, and ensure the control rerenders when that state changes. Preserve the no-arrow behavior when hidden rows are not shown.
Was this helpful? React with 👍 or 👎 to provide feedback.
…s are shown After 734b27a a block with no visible property rows has no collapse arrow. If its hidden properties were shown (the "show hidden properties" toggle) and the block was then collapsed, there was no arrow to open it again, so the hidden rows could not be reached. `db-collapsable?` now also counts the block's hidden rows while the block is in the per-block set the properties area uses to show them. That set moves from `frontend.components.property` to `frontend.state` (`*show-hidden-properties-block-ids`) so the editor handler can read it; the toggle and its hook keep their behaviour. `block-control` uses the hook so the arrow rerenders when the block's hidden rows are shown or hidden. A block whose hidden rows are not shown still has no arrow. The test shows the hidden rows of a block and checks that it is collapsable, that another block with the same kind of rows is not, and that it stops being collapsable once the rows are hidden again. Refs logseq/db-test#1189
|
Thanks, that was a real gap. Fixed in 11e6706. Change
Test
Not covered: the global "show empty and hidden properties" mode ( |
|
Combined into #13870 with the other PRs of this theme, to keep the number of open PRs down; the commits are unchanged there. |
Fixes logseq/db-test#1189, logseq/db-test#1417, logseq/db-test#1041, logseq/db-test#1391, logseq/db-test#1207.
Five editor and selection UI bugs, one commit each, plus a follow-up commit for #1189 (see below). They touch separate code; the only shared file is
editor.cljs(two small hunks, one line and one function body), so the changes stay small next to #13782 and #13865.What the user sees
/deadline,/scheduled, date properties), choosing a day with the arrow keys and pressing Enter saves today's date or the old value instead of the chosen day, or sets it and then reverts it.Cause
db-collapsable?counted every property key on the block. The properties area renders only the visible rows of the block's display properties, so hidden properties made the block look expandable.delete-block-when-zero-pos!read the list type fromstate/get-edit-block, which is captured when editing starts and still has:logseq.property/order-list-typeafter the first Backspace removed it.initial-day, the day the picker opened on. The later call overwrote the first.:on-pointer-downand opened the confirmation; the pointer-up of the same press counted as an outside click and closed it.Change
:block.temp/display-properties,db-collapsable?counts only its:full-propertiesrows. Blocks without it keep the key-based check; query blocks stay collapsable.db-collapsable?also counts its:hidden-propertiesrows, so a block that was collapsed with its hidden rows shown still has an arrow to reopen them. A block whose hidden rows are not shown still has no arrow. The per-block set moved fromfrontend.components.propertytofrontend.state(*show-hidden-properties-block-ids) so the editor handler can read it;toggle-hidden-properties-visibility!,hidden-properties-visible?and the hook behave as before, and the hook (use-hidden-properties-visible) is now public soblock-controlcan use it to rerender the arrow when the state changes. Not covered: the global "show empty and hidden properties" mode also renders hidden rows; the arrow does not account for it.(own-order-number-list? (latest-renderer-block block)), assave-current-block!already reads the current block.confirm-initial-day-on-enter!. It no longer selects the opening day when Enter comes from a calendar day. It still stops the event, and still confirms the opening day when the focus is elsewhere in the picker. The datetime picker (Deadline, Scheduled) still stays open after a day is chosen so the time can be set; that is unchanged.dialog-selected-blocks. Tags, Set property and Unset property pass blocks only when the caller supplied its own selection (table or query view); for the outliner selection they pass none and the dialog reads the selection when it opens. Copy and Add comment still use the blocks loaded at render (not changed here).trash-button-handlers. The delete runs on click; the pointer-down is still stopped so the press does not clear the selection.Tests
db-collapsable-ignores-hidden-properties-test(editor_test): hidden-only rows are not collapsable, a visible row is, a query block with no rows is.db-collapsable-ignores-hidden-properties-testalso covers the follow-up: with the block's hidden rows shown it is collapsable, another block is not, and it stops being collapsable when the rows are hidden again. Without the follow-up change editor-test has 1 failure (the shown-rows assertion); with it, editor-test and the whole unit suite pass.backspace-in-numbered-block-uses-the-latest-list-type-test(editor_test): the first Backspace removes the list type; the second, when the renderer block has no list type but the edit block still does, deletes the block.enter-on-a-calendar-day-does-not-confirm-the-opening-day-test(value_test): Enter on a calendar day selects nothing, elsewhere in the picker selects the opening day, in a form control selects nothing.dialog-selected-blocks-reads-the-outliner-selection-when-the-dialog-opens-testandtrash-button-confirms-on-click-not-pointer-down-test(new selection_test).Proof: with the three source files reverted, the new tests fail (editor-test: 2 failures; value-test: 3 failures; selection-test: 3 failures and 1 error). With the fixes, editor-test (114 tests), value-test (56) and selection-test (2) pass, and the whole unit suite passes. For #1041, #1391 and #1207 the "without" build used the old logic placed inside the new helper functions, since the tests call those helpers.
Not checked in a running app: #1041, #1391 and #1207 are event-timing bugs and the unit tests cover the decision logic, not the browser sequence. #1189 relies on
:block.temp/display-propertiesbeing present on the rendered block, whichrender-data?blocks have.