Skip to content

Commit

Permalink
Merge pull request #22432 from highcharts/dash/22208-editmode-toggle-…
Browse files Browse the repository at this point in the history
…state

dash/22208-editmode-toggle-state
  • Loading branch information
sebastianbochan authored Dec 27, 2024
2 parents bb25d58 + 5c3b7dd commit 02b5dd6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ts/Dashboards/EditMode/EditContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class EditContextMenu extends Menu {
getValue: function (item: MenuItem): boolean {
return item.menu.editMode.isActive();
},
setValue: function (item: MenuItem, value: boolean): void {
const inputElem = item.innerElement?.querySelector('input');

if (inputElem) {
inputElem.checked = value;
}
},
langKey: 'editMode',
events: {
click: function (this: MenuItem): void {
Expand Down Expand Up @@ -167,6 +174,18 @@ class EditContextMenu extends Menu {
);
}
}

// Set editMode toggle state
const toggleEditMode = this.activeItems.find(
(item): boolean => item.options.langKey === 'editMode'
);

if (toggleEditMode) {
(toggleEditMode.options as MenuItem.ToggleOptions).setValue(
toggleEditMode,
this.editMode.isActive()
);
}
}

public updatePosition(
Expand Down
1 change: 1 addition & 0 deletions ts/Dashboards/EditMode/Menu/MenuItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ namespace MenuItem {
export interface ToggleOptions extends ItemOptions {
type: 'toggle';
getValue?: (item: MenuItem) => boolean;
setValue: (item: MenuItem, value: boolean) => void;
events: {
update?: Function;
click: Function;
Expand Down

0 comments on commit 02b5dd6

Please sign in to comment.