[Editor] Make the altText dialog labels part of telemetry (PR 16987 follow-up)

Radio-buttons can also be toggled by clicking on their associated `label`-elements, and not only the `input`-elements itself, however it seems that "pointerdown" event listeners don't cover that case.
Hence it's possible that telemetry could miss certain cases of a mouse being used, and the easiest solution seem to be to instead use "click" event listeners and just ignore keyboard-based events.
This commit is contained in:
Jonas Jenwald 2023-09-22 12:26:03 +02:00
parent 2fc8ab3477
commit ee5b8bcf9e

View File

@ -20,7 +20,7 @@ class AltTextManager {
#boundSetPosition = this.#setPosition.bind(this); #boundSetPosition = this.#setPosition.bind(this);
#boundPointerDown = this.#pointerDown.bind(this); #boundOnClick = this.#onClick.bind(this);
#currentEditor = null; #currentEditor = null;
@ -133,7 +133,7 @@ class AltTextManager {
this.#hasUsedPointer = false; this.#hasUsedPointer = false;
for (const element of this._elements) { for (const element of this._elements) {
element.addEventListener("pointerdown", this.#boundPointerDown); element.addEventListener("click", this.#boundOnClick);
} }
const { altText, decorative } = editor.altTextData; const { altText, decorative } = editor.altTextData;
@ -243,7 +243,7 @@ class AltTextManager {
} }
#close() { #close() {
this.#removePointerDownListeners(); this.#removeOnClickListeners();
this.#uiManager?.addEditListeners(); this.#uiManager?.addEditListeners();
this.#eventBus._off("resize", this.#boundSetPosition); this.#eventBus._off("resize", this.#boundSetPosition);
this.#currentEditor = null; this.#currentEditor = null;
@ -283,14 +283,17 @@ class AltTextManager {
this.#finish(); this.#finish();
} }
#pointerDown() { #onClick(evt) {
if (evt.detail === 0) {
return; // The keyboard was used.
}
this.#hasUsedPointer = true; this.#hasUsedPointer = true;
this.#removePointerDownListeners(); this.#removeOnClickListeners();
} }
#removePointerDownListeners() { #removeOnClickListeners() {
for (const element of this._elements) { for (const element of this._elements) {
element.removeEventListener("pointerdown", this.#boundPointerDown); element.removeEventListener("click", this.#boundOnClick);
} }
} }