1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-02-15 07:25:54 +00:00

Ignore excessive keydown events in charts (#24523)

* Ignore excessive keydown events in charts

* lint
This commit is contained in:
Petar Petrov
2025-03-06 12:30:17 +02:00
committed by GitHub
parent 75edc5132b
commit cdfe4b53bf

View File

@@ -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() });
@@ -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() });