#41231 closed defect (bug) (fixed)
media-views.js: Cannot read .length of undefined (this.controller.$uploaderToggler.length)
Reported by: | Blackbam | Owned by: | joemcgill |
---|---|---|---|
Milestone: | 4.8.1 | Priority: | normal |
Severity: | major | Version: | 4.8 |
Component: | Media | Keywords: | good-first-bug has-patch |
Focuses: | accessibility, javascript, administration | Cc: |
Description
Some change in media-views.js destroyed all my custom scripts regarding media libraries when updating WordPress to the most recent version. I do not know what $uploaderToggler is however if it is not defined the script should not stop execution.
media-views.js lines 8228 - 8242 - currently:
show: function() { this.$el.removeClass( 'hidden' ); if ( this.controller.$uploaderToggler.length ) { this.controller.$uploaderToggler.attr( 'aria-expanded', 'true' ); } }, hide: function() { this.$el.addClass( 'hidden' ); if ( this.controller.$uploaderToggler.length ) { this.controller.$uploaderToggler .attr( 'aria-expanded', 'false' ) // Move focus back to the toggle button when closing the uploader. .focus(); } }
How to fix:
show: function() { this.$el.removeClass( 'hidden' ); if ( this.controller.$uploaderToggler && this.controller.$uploaderToggler.length ) { this.controller.$uploaderToggler.attr( 'aria-expanded', 'true' ); } }, hide: function() { this.$el.addClass( 'hidden' ); if ( this.controller.$uploaderToggler && this.controller.$uploaderToggler.length ) { this.controller.$uploaderToggler .attr( 'aria-expanded', 'false' ) // Move focus back to the toggle button when closing the uploader. .focus(); } }
Please repair this in future versions.
Attachments (2)
Change History (10)
#2
@
7 years ago
- Focuses accessibility added
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 4.8.1
- Owner set to joemcgill
- Status changed from new to assigned
#5
@
7 years ago
- Status changed from assigned to reviewing
Thanks @yahil. At first glance this patch looks exactly right.
#6
@
7 years ago
After looking more closely, this patch needed to be applied in src/wp-includes/js/media/views/uploader/inline.js
since media-views.js
gets autogenerated by Browserify.
41231.2.patch applies the change to src/wp-includes/js/media/views/uploader/inline.js
as well.
Note: See
TracTickets for help on using
tickets.
Thanks @Blackbam,
Looks like this was added in [40359].