Skip to content

Commit d16bb2c

Browse files
committed
fix to not add buttons all the time
1 parent aa16709 commit d16bb2c

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/core/treeStructure.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,22 @@ export class AACPage {
487487
this._pendingMutations.push({ type: 'addButton', button });
488488
}
489489

490+
/**
491+
* Internal load-path button push: adds a button to the page WITHOUT recording a mutation.
492+
* Used by processors during loadIntoTree so the loaded baseline isn't treated as user changes.
493+
* Not part of the public API — consumers should always use addButton.
494+
*/
495+
_loadButton(button: AACButton): void {
496+
this.buttons.push(button);
497+
498+
/**
499+
* Discard all recorded mutations on this page.
500+
* Useful as an escape hatch after loadIntoTree if the consumer wants a clean baseline.
501+
*/
502+
clearMutations(): void {
503+
this._pendingMutations = [];
504+
}
505+
490506
/**
491507
* Get the list of pending mutations for this page (read-only)
492508
*/

src/processors/gridsetProcessor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,8 +1749,8 @@ class GridsetProcessor extends BaseProcessor {
17491749
},
17501750
});
17511751

1752-
// Add button to page
1753-
page.addButton(button);
1752+
// Add button to page (load path: do not record as a user mutation)
1753+
page._loadButton(button);
17541754

17551755
// Place button in grid layout (handle colspan/rowspan)
17561756
for (let r = cellY; r < cellY + rowSpan && r < maxRows; r++) {

0 commit comments

Comments
 (0)