Skip to content

Commit

Permalink
Fixes #15961: Fix secret toggle button by avoiding duplicate event ha…
Browse files Browse the repository at this point in the history
…ndler
  • Loading branch information
jeremystretch committed May 6, 2024
1 parent 4cc5079 commit 4becede
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
18 changes: 9 additions & 9 deletions netbox/project-static/dist/netbox.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion netbox/project-static/dist/netbox.js.map

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions netbox/project-static/src/buttons/secretToggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,17 @@ function handleSecretToggle(state: StateManager<SecretState>, button: HTMLButton
toggleSecretButton(hidden, button);
}

function toggleCallback(event: MouseEvent) {
handleSecretToggle(secretState, event.currentTarget as HTMLButtonElement);
}

/**
* Initialize secret toggle button.
*/
export function initSecretToggle(): void {
hideSecret();
for (const button of getElements<HTMLButtonElement>('button.toggle-secret')) {
button.addEventListener(
'click',
event => {
handleSecretToggle(secretState, event.currentTarget as HTMLButtonElement);
},
false,
);
button.removeEventListener('click', toggleCallback);
button.addEventListener('click', toggleCallback);
}
}

0 comments on commit 4becede

Please sign in to comment.