Skip to content

Gallery Block: Opening Media Library second time results in console error #71579

@DarkMatter-999

Description

@DarkMatter-999

Description

When trying to open Media Library second time, it results in a console error.

The error is as follows:

media-views.js?ver=6.9-alpha-60093-src:1868 
Uncaught TypeError: Cannot read properties of undefined (reading 'className')
    at child.ready (media-views.js?ver=6.9-alpha-60093-src:1868:44)
    at triggerEvents (backbone.js?ver=1.6.0:334:57)
    at triggerApi (backbone.js?ver=1.6.0:322:19)
    at eventsApi (backbone.js?ver=1.6.0:110:16)
    at Events.trigger (backbone.js?ver=1.6.0:312:5)
    at wp.Backbone.Subviews.ready (wp-backbone.js?ver=6.9-alpha-60093-src:393:14)
    at underscore.js?ver=1.13.7:1456:47
    at map (underscore.js?ver=1.13.7:1354:24)
    at _$1.<anonymous> (underscore.js?ver=1.13.7:1447:12)
    at _$1.invoke (underscore.js?ver=1.13.7:76:29)

While researching, we found that it appears to be related to #62168.
When testing with other media blocks for the same behavior we found that the id (__wp-uploader-id-xx) remains unchanged if we dont update the gallery, due to which when opening again it cannot find the frame.

cc: @USERSATOSHI

Step-by-step reproduction instructions

  1. Create a new post.
  2. Add Gallery Block.
  3. Click on Media Library button.
  4. Close the Modal without selecting anything.
  5. Click on Media Library button again.
  6. Check the console for errors.

Screenshots, screen recording, code snippet

Screen.Recording.2025-09-10.at.4.40.47.PM.mov

Environment info

  • WordPress: 6.9-alpha-60272
  • PHP: 8.2.29
  • Server: Apache/2.4.65 (Debian)
  • Database: mysqli (Server: 11.8.3-MariaDB-ubu2404 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 138.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.3
  • MU Plugins: None activated
  • Plugins:
    • Gutenberg 21.6.0-rc.1

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

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Block] GalleryAffects the Gallery Block - used to display groups of images[Type] BugAn existing feature does not function as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions