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

Editable state isn't reactive #2850

Closed
2 tasks done
chrispiech opened this issue Jun 6, 2022 · 4 comments
Closed
2 tasks done

Editable state isn't reactive #2850

chrispiech opened this issue Jun 6, 2022 · 4 comments
Labels
Info: Stale The issue or pullrequest has not been updated in a while and might be stale Type: Bug The issue or pullrequest is related to a bug

Comments

@chrispiech
Copy link

What’s the bug you are facing?

Changing the editor state (for example):
editor.setEditable

Doesn't creative a reactive change to
props.editor.isEditable

Which prevents Nodes from reacting to a change to the editable state

Which browser was this experienced in? Are any special extensions installed?

all!

How can we reproduce the bug on our side?

Create an editor
Create a custom Node
editor.setEditable(false)
Notice that code in the Node
useEffect(()=> {
alert('test')
}, [props.editor.isEditable])
is not fired

Can you provide a CodeSandbox?

No response

What did you expect to happen?

I expected it to have a reactive state change

Anything to add? (optional)

No response

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@chrispiech chrispiech added the Type: Bug The issue or pullrequest is related to a bug label Jun 6, 2022
@Dreched
Copy link

Dreched commented Jun 9, 2022

A CodeSandbox reproducing the issue is located here.

@bdbch
Copy link
Contributor

bdbch commented Jun 27, 2022

Hey @chrispiech @Dreched

While the isEditable value is not reactive by default, I pushed a change (see #2935) that should allow you to track the state of the editors editable state on your own.

It could look something like this:

const [isEditable, setIsEditable] = useState(false)

const editor = useEditor(
  ...
  onUpdate(props) {
    setIsEditable(props.editor.isEditable)
  }
)

You can then use that state to make all of your components reactive (for example via context or any other state management solution).

@github-actions
Copy link
Contributor

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Info: Stale The issue or pullrequest has not been updated in a while and might be stale label Aug 12, 2022
@i-am-the-slime
Copy link

Is this meant to work now or did this just get closed because it was stale for a week?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Info: Stale The issue or pullrequest has not been updated in a while and might be stale Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

4 participants