Skip to content

Commit 8ca17ee

Browse files
committed
Group button missing shortcut
In the calc Data notebookbar tab, there is no shortcut for Group. probably since: commit 7e83016 Date: Wed Aug 6 15:24:33 2025 +0530 feat: Implement group labels and overflow management in Calc notebookbar The overflow group data-group and its bigtoolitem child shared the same id. When the accessibility code processes the bigtoolitem, querySelector('#data-group.ui-overflow-group') matches the parent overflow group instead of finding the button, so the Group button's shortcut is never registered. Add a test for this and fix the other cases found in the other apps that were not yet audited. Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com> Change-Id: Iec07a2722de4e0bde24881389df7aa47af1ec06b
1 parent 9ee4579 commit 8ca17ee

File tree

4 files changed

+75
-3
lines changed

4 files changed

+75
-3
lines changed

browser/src/app/A11yValidator.ts

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ class A11yValidator {
378378

379379
let errorCount = this.validateContainer(notebookbar.container);
380380
errorCount += this.checkTabContainerConsistency(notebookbar);
381+
errorCount += this.checkOverflowGroupChildIds(notebookbar);
381382

382383
if (errorCount === 0) {
383384
console.error('A11yValidator: notebookbar passed all checks');
@@ -423,6 +424,77 @@ class A11yValidator {
423424

424425
return errorCount;
425426
}
427+
428+
private checkOverflowGroupChildIds(notebookbar: any): number {
429+
const selectedTab = document.querySelector(
430+
'.ui-tab.notebookbar.selected',
431+
) as HTMLElement;
432+
if (!selectedTab || !selectedTab.id) return 0;
433+
434+
const tabName = selectedTab.id.split('-')[0];
435+
const containerId = tabName + '-container';
436+
437+
const fullJSON = notebookbar.getFullJSON();
438+
const tabJSON = this.findJSONNodeById(fullJSON, containerId);
439+
if (!tabJSON) return 0;
440+
441+
let errorCount = 0;
442+
443+
const walk = (node: any): void => {
444+
if (!node || !node.children || !Array.isArray(node.children)) return;
445+
446+
for (const child of node.children) {
447+
if (child.type === 'overflowgroup' && child.id) {
448+
this.findDuplicateIdInChildren(
449+
child.id,
450+
child.children,
451+
(dupId: string) => {
452+
console.error(
453+
new A11yValidatorException(
454+
`Overflow group '${dupId}' contains a child with the same id. This breaks accessibility shortcut resolution because querySelector matches the parent instead of the child.`,
455+
),
456+
);
457+
errorCount++;
458+
},
459+
);
460+
}
461+
walk(child);
462+
}
463+
};
464+
465+
walk(tabJSON);
466+
return errorCount;
467+
}
468+
469+
private findJSONNodeById(node: any, id: string): any {
470+
if (!node) return null;
471+
if (node.id === id) return node;
472+
if (node.children && Array.isArray(node.children)) {
473+
for (const child of node.children) {
474+
const found = this.findJSONNodeById(child, id);
475+
if (found) return found;
476+
}
477+
}
478+
return null;
479+
}
480+
481+
private findDuplicateIdInChildren(
482+
parentId: string,
483+
children: any[],
484+
onDuplicate: (id: string) => void,
485+
): void {
486+
if (!children || !Array.isArray(children)) return;
487+
488+
for (const child of children) {
489+
if (child.id === parentId) {
490+
onDuplicate(parentId);
491+
return;
492+
}
493+
if (child.children) {
494+
this.findDuplicateIdInChildren(parentId, child.children, onDuplicate);
495+
}
496+
}
497+
}
426498
}
427499

428500
window.app.a11yValidator = new A11yValidator();

browser/src/control/Control.NotebookbarCalc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2434,7 +2434,7 @@ window.L.Control.NotebookbarCalc = window.L.Control.NotebookbarWriter.extend({
24342434
'accessibility': { focusBack: true, combination: 'GA', de: null },
24352435
'children' : [
24362436
{
2437-
'id': 'data-group',
2437+
'id': 'data-data-group',
24382438
'type': 'bigtoolitem',
24392439
'text': _UNO('.uno:Group'),
24402440
'command': '.uno:Group',

browser/src/control/Control.NotebookbarDraw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1669,7 +1669,7 @@ window.L.Control.NotebookbarDraw = window.L.Control.NotebookbarImpress.extend({
16691669
'accessibility': { focusBack: true, combination: 'TI', de: null },
16701670
'children' : [
16711671
{
1672-
'id': 'insert-text',
1672+
'id': 'insert-insert-text',
16731673
'type': 'bigtoolitem',
16741674
'text': _UNO('.uno:Text'),
16751675
'command': '.uno:Text',

browser/src/control/Control.NotebookbarImpress.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ window.L.Control.NotebookbarImpress = window.L.Control.NotebookbarWriter.extend(
17281728
'accessibility': { focusBack: true, combination: 'IX', de: null },
17291729
'children' : [
17301730
{
1731-
'id': 'insert-text',
1731+
'id': 'insert-insert-text',
17321732
'type': 'bigtoolitem',
17331733
'text': _UNO('.uno:Text'),
17341734
'command': '.uno:Text',

0 commit comments

Comments
 (0)