Skip to content

Adding Tag property using Javascript or Plugin API produes empty tag #390

@OptionalLion411

Description

@OptionalLion411

Search first

  • I searched and no similar issues were found

What Happened?

I am using the DB version and try to develop a plugin using "@logseq/libs" 0.2.1. But when I try to add tags to any block, there is always an empty tag inserted automtically which breaks further access of this block. I get this behavior with logseq.Editor.insertBlock(src, content, {properties: {"block/tags": ["example"]}}) as well as when using logseq.Editor.upsertBlockProperty(src, "block/tags", ["example"]).

This is the block data I see after creating a block using the methods listened above:

 :block/uuid #uuid "687536da-40e5-47e1-a867-cb2ce47ba2a2",
 :block/updated-at 1752512226220,
 :block/refs [{:db/id 9} {:db/id 21} {:db/id 1717}],
 :block.debug/properties {:block/tags #{nil "example"}},
 :block/created-at 1752512218027,
 :block.debug/refs [{:db/id 9} "Tags" "example"],
 :block/tags [{:db/id 9} {:db/id 1717}],
 :block/title "Entry",
 :db/id 1716,
 :block.temp/load-status :self,
 :block/path-refs
 [{:db/id 1}
  {:db/id 2}
  {:db/id 9}
  {:db/id 21}
  {:db/id 38}
  {:db/id 1528}
  {:db/id 1717}],
 :block/parent {:db/id 1528},
 :block/order "aI",
 :block/page {:db/id 1528}}

As you can see, there's some :block/tags #{nil "example"} where the nil causes the problem, I think.
This screenshot shows the rendering of the block in the UI:

Image

I forgot the used methods, but this Bug is also present when creating or modifying blocks using the Javascript Console.

Reproduce the Bug

  1. Start a plugin using the latest template and change "@logseq/libs" version to 0.2.1 for DB support.
  2. Paste a valid method call of logseq.Editor.insertBlock(src, "Exampls block", {properties: {"block/tags": ["example"]}}) using a valid Pagesrc for example.
  3. Load the plugin and have a look at the newly created block. There should be two tags: "example" and an empty tag.

Expected Behavior

The newly created block should only have the "example" tag.

Files

No response

Browser, Desktop or Mobile Platform Information

Latest Desktop version from build files, Linux amd64.

Additional Context

No response

Are you willing to submit a PR? If you know how to fix the bug.

  • I'm willing to submit a PR (Thank you!)

Metadata

Metadata

Labels

bugSomething isn't workingplugins

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions