[FIX] web_editor: don't show the active style entry if absent
Steps to follow - Edit a report with studio - Add an inline text element - Select it - Select the text in the sidebar -> An error is raised Cause of the issue firstButtonEl is undefined because the style section is not always present in the toolbar opw-2674302 closes odoo/odoo#79335 X-original-commit: 45b590d8961d56f8d207c22efbf1ba7188a3b1fa Signed-off-by: David Monjoie (dmo) <dmo@odoo.com> Signed-off-by: Hubert Van De Walle <huvw@odoo.com>
This commit is contained in:
@@ -1886,14 +1886,18 @@ export class OdooEditor extends EventTarget {
|
||||
listDropdownButton.closest('button').classList.toggle('active', block.tagName === 'LI');
|
||||
}
|
||||
}
|
||||
if (!activeLabel) {
|
||||
// If no element from the text style dropdown was marked as active,
|
||||
// mark the paragraph one as active and use its label.
|
||||
const firstButtonEl = this.toolbar.querySelector('#paragraph');
|
||||
firstButtonEl.classList.add('active');
|
||||
activeLabel = firstButtonEl.textContent;
|
||||
|
||||
const styleSection = this.toolbar.querySelector('#style');
|
||||
if (styleSection) {
|
||||
if (!activeLabel) {
|
||||
// If no element from the text style dropdown was marked as active,
|
||||
// mark the paragraph one as active and use its label.
|
||||
const firstButtonEl = styleSection.querySelector('#paragraph');
|
||||
firstButtonEl.classList.add('active');
|
||||
activeLabel = firstButtonEl.textContent;
|
||||
}
|
||||
styleSection.querySelector('button span').textContent = activeLabel;
|
||||
}
|
||||
this.toolbar.querySelector('#style button span').textContent = activeLabel;
|
||||
|
||||
const linkNode = getInSelection(this.document, 'a');
|
||||
const linkButton = this.toolbar.querySelector('#createLink');
|
||||
|
||||
Reference in New Issue
Block a user