Skip to content

Commit

Permalink
jsdialog: prevent errors on treeview context menu
Browse files Browse the repository at this point in the history
Fixes error when trying to open context menu on "Contents 3" node in
the style sidebar in Writer

global.js:566 Exception SyntaxError: Failed to execute 'querySelector' on 'Element': '.unoContents 3' is not a valid selector. emitting event jsdialog: { "children": [ { "id": "__MENU__", "type": "menu", "count": 5, "entries": [ { "row": "new", "columns": [ { "text": "New..."}]}, { "row": "edit", "columns": [ { "text": "Edit Style..."}]}, { "row": "hide", "columns": [ { "text": "Hide"}]}, { "row": "show", "columns": [ { "text": "Show"}]}, { "row": "delete", "columns": [ { "text": "Delete..."}]}]}], "jsontype": "dialog", "type": "dropdown", "cancellable": true, "popupParent": "treeview", "clickToClose": "Contents 3", "id": 0}
SyntaxError: Failed to execute 'querySelector' on 'Element': '.unoContents 3' is not a valid selector.
    at NewClass.addHandlers (https://localhost:9980/browser/9a61792f5d/src/control/Control.JSDialog.js:327:51)
    at NewClass.onJSDialog (https://localhost:9980/browser/9a61792f5d/src/control/Control.JSDialog.js:648:18)

Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I78dbc41eb1117f2c9adba4a21390fd908e8b8f9f
  • Loading branch information
eszkadev committed Jan 7, 2025
1 parent 03f9cf4 commit 2301318
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion browser/src/control/Control.JSDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,8 @@ L.Control.JSDialog = L.Control.extend({

this.addFocusHandler(instance); // Loop focus for all dialogues.

var clickToCloseId = instance.clickToClose;
var clickToCloseId = instance.clickToClose
? instance.clickToClose.replaceAll(' ', '') : null;
if (clickToCloseId && clickToCloseId.indexOf('.uno:') === 0)
clickToCloseId = clickToCloseId.substr('.uno:'.length);

Expand Down
Binary file added cypress_test/data/desktop/writer/stylebar.odt
Binary file not shown.
19 changes: 19 additions & 0 deletions cypress_test/integration_tests/desktop/writer/stylebar_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* global describe it cy beforeEach require */

var helper = require('../../common/helper');

describe(['tagdesktop'], 'Test style sidebar', function() {

beforeEach(function() {
helper.setupAndLoadDocument('writer/stylebar.odt');

cy.cGet('#Format-tab-label').click();
cy.cGet('#format-style-dialog').click();
});

it('Style sidebar context menu on node with spaces', function() {
cy.cGet('#treeview .ui-treeview-cell-text').contains('Complimentary Close').click();
cy.cGet('#treeview .ui-treeview-cell-text').contains('Complimentary Close').rightclick();
cy.cGet('#__MENU__').should('exist');
});
});

0 comments on commit 2301318

Please sign in to comment.