-
Notifications
You must be signed in to change notification settings - Fork 384
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
Duplicating CTA / Page Attachment block crashes browser #3467
Comments
The keyboard shortcut CTRL+Shift+D also has the same effect. |
Looking into this. |
I'm adding another AC:
Haven't looked into the code yet but we have a logic in place that is trying to set the CTA block to be the last on a Page -- if there would be two CTA blocks then that most likely would cause infinite updating. Having 2 CTA blocks shouldn't be allowed anyway, however, warning instead of crashing and/or removing the extra CTA block if this should happen for some reason would be good, too. |
That sounds like a plausible cause 👍 Preventing wherever possible makes sense, though we cannot remove the keyboard shortcut or the option from the menu at the moment. |
Ah, okay, thought that it's the context menu but it's happening in case of the default More Options Menu, and that can't be removed. I guess the same should go for the Page Attachment block as well then -- that also triggers the enforcing being the last block logic. Any objections to adding Page Attachment to this issue as well since it's basically the same issue? |
works for me 👍 |
To confirm with UX: Otherwise IB ready. |
Updated the IB to add the snack-bar notification. Ready for review now. |
I think this speaks into the larger issue of customising the "More Options" menu (the Gutenberg term is
There are some checks for some of these things we want to do (the component has a Should we (rather than fix this single issue only) look into either:
Or maybe even both, as the latter has a longer turn-around. Note: We also want to add custom menu items, but that's already possible through the |
It might make sense fixing this issue first as a bugfix and additionally create a follow-up issue for looking into generally replacing the Thoughts? |
I looked into customizing those components in #3504 (comment), where it seems like replacing those is not easily possible. Upstream contributions might be possible, but it's unsure whether these would be (a) accepted and (b) implemented in time. It's one of the many symptoms of the reliance on Gutenberg. As discussed in today's meeting, I am planning on writing a more detailed design doc based on #2554 to plan a bigger technical overhaul of the stories editor. This would reduce the strong dependency on Gutenberg to gain more control over the whole editor UI. |
I spent a fair bit of time looking at change or removing the I have said before, I believe the context menu that is shown when right clicking should be shown here, when a block is selected. It would keep the two menus in line and make it easier to find the right click options via screen readers etc. I agree with above statements that we should fix the root issue, as they maybe other ways we haven't thought of yet to copy CTA / attachment blocks. |
Note that considering the RC this Friday and release next week then that's not a valid option right now. We can "fix" the bug for the release and look into the root issue separately since that will need some planning and will take quite some time to figure out a general best solution + implement it. Probably would be good to continue the discussion in a separate dedicated issue outside of this bugfix issue. |
Agree with both of you. Hence the planned design doc in #2554 to evaluate how we can fix the root issue. |
Was unable to duplicate, but the message that appears is: |
I think that this issue is related to WordPress/gutenberg#14515 . If the allow blocks could be change dynamically then the duplicate block would never appear. If we fix this upstream, it would be useful considering these lines of code |
Issue was erroneously closed automatically before completing. Reopening. |
Verified in QA |
Bug Description
In the stories editor, there when a block is a selected, a context menu icon appears in the toolbar that looks like this.
If a CTA block is selected and the duplicate block is selected, the browser becomes unresponsive and sometimes crashes.
There might be some infinite loop, perhaps caused by some faulty React hook somewhere.
Expected Behaviour
Block should fail to duplicate or at least a warning about duplicate CTA blocks is shown.
Steps to reproduce
Screenshots
If the browser doesn't crash, then two CTA blocks are shown.
Additional context
Acceptance criteria
Implementation brief
Reason for crashing
When either a CTA or a Page Attachment block is present on a Page, enforcing the block to be the last block on the Page is triggered. If there are more than one CTA / Page Attachment blocks then this causes the logic to be triggered infinitely since only one block can be the last block:
amp-wp/assets/src/stories-editor/blocks/amp-story-page/edit.js
Lines 145 to 166 in 744b640
Suggested solution
If more than one CTA/Page Attachment blocks are detected then before enforcing the block to be the last, two things should happen:
We could add an additional condition to the same
useEffect
hook that enforces the CTA/Attachment block to be the last, to only run if there is only one CTA or one Page Attachment block. Additionally, we can add anotheruseEffect
which removes the extra block(s) if detected which can also display a snackbar notice saying that the block was removed since each Page can have only 1 CTA block or 1 Attachment block.QA testing instructions
-> Verify that block is not duplicated, but a warning message appears in the bottom left.
-> Verify that block is not duplicated, but a warning message appears in the bottom left.
Demo
https://www.youtube.com/watch?v=iItTJkcF7Qg&feature=youtu.be
Changelog entry
The text was updated successfully, but these errors were encountered: