[wp-trac] [WordPress Trac] #52473: Twenty Twenty-One: Dark Mode toggle is causing JavaScript error in block editor

WordPress Trac noreply at wordpress.org
Tue Feb 9 07:31:59 UTC 2021


#52473: Twenty Twenty-One: Dark Mode toggle is causing JavaScript error in block
editor
---------------------------+-----------------------------------------
 Reporter:  ocean90        |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  5.7
Component:  Bundled Theme  |     Version:  5.6
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:  javascript, administration
---------------------------+-----------------------------------------
Changes (by SergeyBiryukov):

 * milestone:  Future Release => 5.7


Old description:

> For some reasons the `dark-mode-toggler.js` from Twenty Twenty-One is
> also enqueued in the block editor if Dark Mode support is enabled. This
> is causing JavaScript errors if the window (not the editor itself) is
> scrolled.
>
> ```
> Uncaught TypeError: Cannot read property 'classList' of null
>     at checkScroll (dark-mode-toggler.js?ver=1.0.0:56)
> ```
>
> To reproduce enable Dark Mode support in the Customizer and open the
> block editor. Now reduce the height of the window so that you're able to
> scroll the admin menu. Once you scroll you should see the JavaScript
> error from above in the console.
>
> The script should either check that the toggle exists or better not
> enqueued in the block editor at all.

New description:

 For some reasons the `dark-mode-toggler.js` from Twenty Twenty-One is also
 enqueued in the block editor if Dark Mode support is enabled. This is
 causing JavaScript errors if the window (not the editor itself) is
 scrolled.

 {{{
 Uncaught TypeError: Cannot read property 'classList' of null
     at checkScroll (dark-mode-toggler.js?ver=1.0.0:56)
 }}}

 To reproduce enable Dark Mode support in the Customizer and open the block
 editor. Now reduce the height of the window so that you're able to scroll
 the admin menu. Once you scroll you should see the JavaScript error from
 above in the console.

 The script should either check that the toggle exists or better not
 enqueued in the block editor at all.

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52473#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list