Skip to content

Commit

Permalink
This is a shot in the dark: perhaps it is possible to not receive a m…
Browse files Browse the repository at this point in the history
…ouseup event, which would could cause the trouble reported by Yunlai
  • Loading branch information
justvanrossum committed Sep 18, 2023
1 parent 790440c commit da0f128
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/fontra/client/web-components/range-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export class RangeSlider extends LitElement {
this.tickmarksPositions = [];
this.step = "any";
this.sawMouseDown = false;
this.sawMouseUp = false;
this.onChangeCallback = () => {};
}

Expand Down Expand Up @@ -199,6 +200,7 @@ export class RangeSlider extends LitElement {
<input
type="range"
@input=${this.changeValue}
@change=${this.handleChange}
@mousedown=${this.handleMouseDown}
@keydown=${this.handleKeyDown}
@mouseup=${this.handleMouseUp}
Expand Down Expand Up @@ -240,6 +242,7 @@ export class RangeSlider extends LitElement {

handleMouseDown(event) {
this.sawMouseDown = true;
this.sawMouseUp = false;
const activeElement = document.activeElement;
this._savedCanvasElement =
activeElement?.id === "edit-canvas" ? activeElement : undefined;
Expand All @@ -252,9 +255,17 @@ export class RangeSlider extends LitElement {
handleMouseUp(event) {
this._savedCanvasElement?.focus();
this.sawMouseDown = false;
this.sawMouseUp = true;
this.onChangeCallback({ value: this.value, dragEnd: true });
}

handleChange(event) {
if (!this.sawMouseUp) {
this.onChangeCallback({ value: this.value, dragEnd: true });
}
this.sawMouseUp = false;
}

changeValue(event) {
const value = event.target.value;
const isValid = event.target.reportValidity() && isNumeric(value);
Expand Down

0 comments on commit da0f128

Please sign in to comment.