Uncaught TypeError: str is undefined - when contextual links are toggled-on on admin toolbar

Created on 11 December 2024, 27 days ago

Contextual toolbar initializes AuralView with bad initial object. This issue is present in all branches up to 11.x-dev

Steps to reproduce

1. Enable contextual links module and admin toolbar module.
2. On admin toolbar click "Edit" button that shows all contextual menus on a page
3. Refresh page within that state.
4. Observe js console reporting "Uncaught TypeError: str is undefined"

in core/modules/contextual/js/contextual.toolbar.js at line 47 the object viewOptions has 3 properties, but the third one is not keyed

const viewOptions = {
  el: $('.toolbar .toolbar-bar .contextual-toolbar-tab'),
  model: contextualToolbar.model,
  strings,
};

while core/modules/contextual/js/AuralView.js at line 83 tries to access property named "strings"

const strings = this.options.strings;

Proposed resolution

add proper key to third property of this object

const viewOptions = {
  el: $('.toolbar .toolbar-bar .contextual-toolbar-tab'),
  model: contextualToolbar.model,
  strings: strings,
};
🐛 Bug report
Status

Active

Version

10.3

Component

contextual.module

Created by

🇵🇱Poland gravisrs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024