Skip to content

Commit

Permalink
Ignore excessive keydown events in charts (#24523)
Browse files Browse the repository at this point in the history
* Ignore excessive keydown events in charts

* lint
  • Loading branch information
MindFreeze authored Mar 6, 2025
1 parent 75edc51 commit cdfe4b5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/components/chart/ha-chart-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export class HaChartBase extends LitElement {

// Add keyboard event listeners
const handleKeyDown = (ev: KeyboardEvent) => {
if ((isMac && ev.key === "Meta") || (!isMac && ev.key === "Control")) {
if (
!this._modifierPressed &&
((isMac && ev.key === "Meta") || (!isMac && ev.key === "Control"))
) {
this._modifierPressed = true;
if (!this.options?.dataZoom) {
this._setChartOptions({ dataZoom: this._getDataZoomConfig() });
Expand All @@ -123,7 +126,10 @@ export class HaChartBase extends LitElement {
};

const handleKeyUp = (ev: KeyboardEvent) => {
if ((isMac && ev.key === "Meta") || (!isMac && ev.key === "Control")) {
if (
this._modifierPressed &&
((isMac && ev.key === "Meta") || (!isMac && ev.key === "Control"))
) {
this._modifierPressed = false;
if (!this.options?.dataZoom) {
this._setChartOptions({ dataZoom: this._getDataZoomConfig() });
Expand Down

0 comments on commit cdfe4b5

Please sign in to comment.