Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Value onChange event isn't updating when you paste blocks from one editor to another #39

Open
kgrosvenor opened this issue Apr 20, 2022 · 4 comments

Comments

@kgrosvenor
Copy link

kgrosvenor commented Apr 20, 2022

If you paste blocks from one strapi window to another and click save it doesnt reflect when you next load the content type, you can work around it by adding a few chars and removing them and then hitting save

@kgrosvenor kgrosvenor changed the title Value onChange event is't updating when you paste blocks from one editor to another Value onChange event isn't updating when you paste blocks from one editor to another Apr 20, 2022
@kgrosvenor
Copy link
Author

This resolves it in our case

onChange={(api, newData) => {
  if (newData.blocks.length) {
    onChange({target: {name, value: JSON.stringify(newData)}});
  } else {
    api.saver.save().then((res) => {
      onChange({target: {name, value: JSON.stringify(res)}});
    });
  }
}}

@melishev
Copy link
Owner

@kgrosvenor Oh that's amazing, could you send a PR with your changes so we can include them in the package?

@kgrosvenor
Copy link
Author

I shall do this evening @melishev i brought this into our work project like mentioned but will move into this project also and create a PR

@kgrosvenor
Copy link
Author

I went with this in the end since its a same result mostly

onChange={(api) => {
  api.saver.save().then((res) => {
    onChange({target: {name, value: JSON.stringify(res)}});
  });
}}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants