Logseq gets stuck in view mode

I’m not familiar with logseq naming, so I will define what I mean:

  • Edit mode: Mode in which logseq is able to browse through a Page/Journal using the cursors to move through the different blocks and edit them. When this mode is active, you can use the cursors up/down as in a normal text editor.
  • View mode: Mode in which logseq accept sequences of keys to build shortcuts. For example, “Go to Journals” is usually g j.

The bug that I’m reporting is related to the impossibility of Logsec to return to edit mode using the keyboard. Example:

  1. I’m in edit mode in a Journal.
  2. I press ctrl+k to search a page. I select the desired result and press enter. Logseq takes me to the page.
  3. Logseq does not allow me to browse the page using the cursors or it does not allow me to press enter to create a new block.
  4. Going back to the journals or any other page is possible (since I’m still in view mode).

Note that:

  • This is a problem that happens intermittently. In a normal scenario I’m able to browse a page and move through the blocks using the cursors. But once the problem occurs, the view mode gets stuck even if I try to jump to a different page.
  • In all these cases, clicking with the mouse within a page returns Logseq to edit mode. The bug is about not being able to return to edit mode using the keyboard.

Version:
Ubuntu 22.04 using Logseq 0.10.1

Bumping this one because I can still replicate it with 0.10.8 and multiple machines using Ubuntu 22.04

Would you be interested in a workaround like in How can I navigate, with keyboard, to the Right Sidebar’s Cards? If so, which element would you like focused and with which shortcut?

I would be interested, yes, although it looks like this scenario might be different. This is not about adding some new functionality that does not exist, but about the current functionality suddenly breaking until a mouse click is performed to bring back the edit mode.

If you prefer waiting some more months for a fix, that’s fine. If not, answer my questions for the workaround.

I would like to focus the top block of the current page. The shortcut, for example “ctrl+u”

Thank you for offering your help, BTW :bowing_man:

Here you are:

document.addEventListener("keydown", (e)=>{
    if (e.ctrlKey && e.key === "u") {
        const div = document.getElementById("main-container")
        if (!div) return

        const span = div.querySelector("span.inline")
        if (!span) return

        span.dispatchEvent(new MouseEvent("mousedown", {
            bubbles: true,
            cancelable: true
        }))

        function escape(){
            const ta = div.querySelector(".block-editor")
            if (!ta) return

            ta.dispatchEvent(new KeyboardEvent("keydown", {
                bubbles: true,
                keyCode: 27
            }))
        }
        setTimeout(escape, 300)
    }
})

Thank you very much.
The custom event listener works as expected.

Do you know by chance what the bug consist of?
I was able to link it to the use of the shortcut for “Backwards”, that I use together with “Follow Link Under Cursor” as a way of jumping in and out to/from a page.
However, it is not a deterministic behavior.

The times that I’ve been able to replicate it:

  • I navigate through the words of one block until I position the cursor on top of a link.
  • I trigger the shortcut to follow the link.
  • I browse a couple of lines in the destination page.
  • I trigger the shorcut to go back to the previous page.
  • The previous page is loaded correctly in view mode.
  • When trying to use the cursors again to browse the page, the application does not respond to the cursors.
  • Once stuck, you can continue using other shorcuts (for example, you can use ctrl+k and go to other page), but the loaded page remains in view mode until I click inside the page to focus it.