Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Dynamic node spec is not recomputed when node is updated #6197

Open
1 task done
dan-cooke opened this issue Mar 24, 2025 · 0 comments
Open
1 task done

[Bug]: Dynamic node spec is not recomputed when node is updated #6197

dan-cooke opened this issue Mar 24, 2025 · 0 comments
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug

Comments

@dan-cooke
Copy link

Affected Packages

core, react

Version(s)

2.11.4

Bug Description

Up until recently I was able to dynamically set the properties of a NodeSpec by returning a function, for example

export const Image = Node.create({
  draggable() {
    const nonDraggableModes = ['behind', 'infront'];
    if (nonDraggableModes.includes(this.storage.mode)) {
      return false;
    }
    return true;
  },
...
})

Which works fine.,

However this function is not called/recomputed when storage is updated or attributes are changed on the node. Infact it seems this function is never called again.

For example, I have a command like so:

  addCommands() {
    return {

      setImageMode:
        (mode) =>
        ({ commands, editor }) => {
          editor.storage.mode = mode;
          return commands.updateAttributes(this.name, {
            mode: mode,
          });
        },
    };
  },

Which I would expect to trigger draggable to be re-computed

I believe this to be a regression, as this 100% used to work as my code has not been touched in this area for well over a year.

Browser Used

Chrome

Code Example URL

No response

Expected Behavior

dynamic node spec functions are called again whenever the node in question is updated

Additional Context (Optional)

No response

Dependency Updates

  • Yes, I've updated all my dependencies.
@dan-cooke dan-cooke added Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug labels Mar 24, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Tiptap: Issues Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Open Source The issue or pull reuqest is related to the open source packages of Tiptap. Type: Bug The issue or pullrequest is related to a bug
Projects
Status: Needs Triage
Development

No branches or pull requests

1 participant