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

Inserting a Classic block with the slash inserter crashes the editor if the sidebar is open #41321

Closed
priethor opened this issue May 25, 2022 · 13 comments · Fixed by #41328
Closed
Assignees
Labels
[Block] Classic Affects the Classic Editor Block [Type] Bug An existing feature does not function as intended

Comments

@priethor
Copy link
Contributor

priethor commented May 25, 2022

Description

When adding a Classic block in an empty post, the editor crashes.

Step-by-step reproduction instructions

  1. Create a new post
  2. Open the sidebar
  3. Add a Classic block through the slash inserter

Screenshots, screen recording, code snippet

Grabacion.de.pantalla.2022-05-25.a.las.15.01.57.mov

Environment info

  • WordPress 6.0, or WordPress < 6.0 + Gutenberg version >= 13.0
  • Firefox & Chrome

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@priethor priethor added [Type] Bug An existing feature does not function as intended [Priority] High Used to indicate top priority items that need quick attention [Block] Classic Affects the Classic Editor Block labels May 25, 2022
@youknowriad
Copy link
Contributor

I don't seem to be able to reproduce the issue here. Is there some other variable at play here?

@priethor priethor added the Needs Testing Needs further testing to be confirmed. label May 25, 2022
@priethor
Copy link
Contributor Author

priethor commented May 25, 2022

I'm trying to isolate the issue even more. I've just spun up a brand new site using Local and it crashes too. Not only when adding a new post but when adding it to the Hello world! existing one.

This is the error thrown in the console:

    at block-editor.min.js?ver=39c7981dd22ec80281080455892940e6:formatted:22781:26
    at Object.Mt [as useMemo] (react-dom.min.js?ver=17.0.1:9:48138)
    at e.useMemo (react.min.js?ver=17.0.1:9:10749)
    at lk (block-editor.min.js?ver=39c7981dd22ec80281080455892940e6:formatted:22779:23)
    at ct (react-dom.min.js?ver=17.0.1:9:43430)
    at Bt (react-dom.min.js?ver=17.0.1:9:50249)
    at os (react-dom.min.js?ver=17.0.1:9:112112)
    at Ur (react-dom.min.js?ver=17.0.1:9:77643)
    at Ir (react-dom.min.js?ver=17.0.1:9:77571)
    at Dr (react-dom.min.js?ver=17.0.1:9:77434)
rr @ react-dom.min.js?ver=17.0.1:9

@priethor
Copy link
Contributor Author

Testing with previous Gutenberg versions shows:

  • If GB <=12.9, the Classic block works fine.
  • If GB >= 13.0 (which is the last GB version included in WP 6.0), the issue reproduces.

@Mamaduka
Copy link
Member

I'm not able to reproduce the issue. Tested with the following setups on Chrome.

  • WordPress 6.0 with and without Gutenberg 13.2.2.
  • WordPress 6.0 with current Gutenberg trunk.

@priethor, do you have any other plugins active?

@priethor
Copy link
Contributor Author

@priethor, do you have any other plugins active?

I don't, no plugins installed at all.

@mcsf
Copy link
Contributor

mcsf commented May 25, 2022

@priethor:

  1. Can you consistently repro?
  2. Can you pinpoint the location in the minified source (e.g. "prettify" the source)?

@ryanwelcher
Copy link
Contributor

ryanwelcher commented May 25, 2022

@priethor I was able to reproduce this in the Site Editor using TwentyTwentyTwo:

  1. Open the Single Post template
  2. Insert a Classic Block
Site.Editor.Classic.Block.mov

Console outputs the error below.

react-dom.min.js?ver=17.0.1:9 TypeError: Cannot read properties of undefined (reading 'tinymce')
    at block-library.min.js?ver=016c65731f009ca1e5b5974727017d18:14:63022
    at $r (react-dom.min.js?ver=17.0.1:9:83333)
    at unstable_runWithPriority (react.min.js?ver=17.0.1:9:7431)
    at xn (react-dom.min.js?ver=17.0.1:9:29950)
    at Qr (react-dom.min.js?ver=17.0.1:9:82796)
    at Pr (react-dom.min.js?ver=17.0.1:9:74334)
    at react-dom.min.js?ver=17.0.1:9:30173
    at unstable_runWithPriority (react.min.js?ver=17.0.1:9:7431)
    at xn (react-dom.min.js?ver=17.0.1:9:29950)
    at Nn (react-dom.min.js?ver=17.0.1:9:30118)

@Mamaduka
Copy link
Member

Mamaduka commented May 25, 2022

@ryanwelcher, the Classic block isn't supported in Site Editor at the moment - #23086. Also, based on the @priethor screencast, the error isn't caught by the block error boundary.

@ryanwelcher
Copy link
Contributor

@Mamaduka @priethor I think we're looking at two separate issues. Mine seems to be known already so disregard my report. I can't reproduce this happening in the post editor.

@priethor
Copy link
Contributor Author

Can you consistently repro?

Yes, every single time.

Can you pinpoint the location in the minified source (e.g. "prettify" the source)?

Sure, the error is thrown at the return l.forEach in the closure after a.useMemo

           var lk = function(e) {
            let {blockClientId: t} = e;
            const {updateBlockAttributes: n} = (0,
            m.useDispatch)(qn)
              , {activeBlockVariation: o, variations: l} = (0,
            m.useSelect)((e=>{
                const {getActiveBlockVariation: n, getBlockVariations: o} = e(r.store)
                  , {getBlockName: l, getBlockAttributes: i} = e(qn)
                  , a = t && l(t);
                return {
                    activeBlockVariation: n(a, i(t)),
                    variations: a && o(a, "transform")
                }
            }
            ), [t])
              , i = null == o ? void 0 : o.name
              , s = (0,
            a.useMemo)((()=>{
                const e = new Set;
                return l.forEach((t=>{
                    t.icon && e.add(t.icon)
                }
                )),
                e.size === l.length
            }
            ), [l]);
            if (null == l || !l.length)
                return null;
            const c = s ? ok : rk;
            return (0,
            a.createElement)(c, {
                className: "block-editor-block-variation-transforms",
                onSelectVariation: e=>{
                    n(t, {
                        ...l.find((t=>{
                            let {name: n} = t;
                            return n === e
                        }
                        )).attributes
                    })
                }
                ,
                selectedValue: i,
                variations: l
            })
        }

@youknowriad
Copy link
Contributor

@priethor that helps, so I can reproduce now and it's related to this PR #40036

Basically, you need to have the sidebar open before adding the block to reproduce the issue :)

@skorasaurus skorasaurus removed the Needs Testing Needs further testing to be confirmed. label May 25, 2022
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label May 25, 2022
@priethor
Copy link
Contributor Author

priethor commented May 25, 2022

@youknowriad great context, I can confirm the sidebar needs to be open.

Furthermore, testing with @ryanwelcher showed it only crashes when using the slash inserter; when using the normal inserter or the appender it works fine.

@priethor priethor changed the title Adding a new Classic block crashes the editor Inserting a Classic block with the slash inserter crashes the editor if the sidebar is open May 25, 2022
@priethor priethor added [Type] Bug An existing feature does not function as intended and removed [Type] Bug An existing feature does not function as intended [Priority] High Used to indicate top priority items that need quick attention labels May 25, 2022
@nickfmc
Copy link

nickfmc commented May 25, 2022

I can also replicate this issue every time when adding the classic editor on a new page! However I found this post searching for an explanation to why I am seeing other blocks have unexpected errors, the other ones I can't find a way to replicate them yet the way you have with the classic editor.

EDIT - One thing to clarify is that by "sidebar" @priethor is referring to the "Settings pane" NOT whether or not you are in "full screen mode" or not so the RIGHT sidebar, settings pane needs to be open to reproduce.

@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Classic Affects the Classic Editor Block [Type] Bug An existing feature does not function as intended
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants