-
-
Notifications
You must be signed in to change notification settings - Fork 572
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
Fix issue of duplicated blocks upon pasting an image into the Slate E… #5818
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for volto canceled.
|
✅ Deploy Preview for plone-components canceled.
|
Co-authored-by: Steve Piercy <web@stevepiercy.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
News looks good, PR needs review by a maintainer.
@plone/volto-team review requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change log is OK. Code needs review by a maintainer. @plone/volto-team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aryan7081 I wonder how did you test that this code change fixes the issue?
I will attach a video where I record testing your fix and the issue is still present
exactly as it was flagged into the issue so I don't understand what made you belive that this issue would be fixed by your change.
slate-image-pasting.mp4
If you still want to try to work on this issue, your pull request needs to contain
a cypress test that uploads an image, you copy the image to the clipboard and you paste it in a page as you can see from this video:
copy-uploaded-image.mp4
EDIT:
Then your test should show that when you paste the image inside the empty slate block, the image is pasted inside that
block instead of leaving that initial slate block empty.
@aryan7081 A couple of extra context as upon further testing I noticed the following:
|
@ichim-david Sorry for the delay. Working on this and adding tests as well. Can I test this on linux and windows vm? |
@aryan7081 do the minimum test first on whatever platform you're working on and if you can reproduce the issue there then try to fix it, there is no point in doing cross-testing until necessary. |
The
This change ensures that a block is inserted at the (index - 1) position if the current(index) block is empty. Otherwise, it proceeds to create another block as usual. Will push cypress tests once this approach is validated. Screen.Recording.2024-03-07.at.9.01.39.PM.MOV |
@aryan7081 please run code quality checks locally before pushing commits. See Linting. However our documentation lacks the specific commands that need to be run, so I don't blame you for not running undocumented commands. See #5341 The CI jobs call https://github.com/plone/volto/blob/main/.github/workflows/code-analysis.yml. You can look at it for the commands that do not pass the checks, and try running them locally. |
@stevepiercy Working on cypress tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aryan7081 I tried it out, and it does work well indeed.
We would need the tests if possible. We improved the documentation lately:
https://6.docs.plone.org/volto/contributing/acceptance-tests.html
Also, the code analysis checks are failing.
Could you imagine in work on this?
Fixes Issue
Inside the onImageLoad function in withDeserializers extension of Volto Slate.
uploadContent adds the block using Redux and FormData, but the .then promise callback of uploadContent also adds a new Node in the Slate Editor using
Transforms.insertNodes(editor, image);
which eventually leads to adding multiple images in the editor.