Skip to content

Commit

Permalink
Remove overridden function
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardHelm committed Nov 4, 2024
1 parent 72d9f38 commit 09e199b
Showing 1 changed file with 8 additions and 33 deletions.
41 changes: 8 additions & 33 deletions libs/components/src/lib/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ export class Slider extends FormAssociatedSlider {
}

protected keypressHandler = (e: KeyboardEvent) => {
this._focusVisible = true;

if (this.readOnly) {
return;
}
Expand Down Expand Up @@ -447,7 +449,9 @@ export class Slider extends FormAssociatedSlider {
if (this.readOnly || this.disabled || event.defaultPrevented) {
return;
}
this.#isNonVisibleFocus = true;
(event.target as HTMLElement).focus();
this.#isNonVisibleFocus = false;
}
const eventAction =
event !== null ? 'addEventListener' : 'removeEventListener';
Expand Down Expand Up @@ -533,10 +537,14 @@ export class Slider extends FormAssociatedSlider {
if (e) {
e.preventDefault();
this.setupTrackConstraints();
this.#isNonVisibleFocus = true;
(e.target as HTMLElement).focus();
this.#isNonVisibleFocus = false;
const value = this.#calculateValueFromMouseEvent(e);

this.value = `${this.#roundToNearestStep(value)}`;

this.isDragging = true;
}
}
};
Expand Down Expand Up @@ -597,39 +605,6 @@ export class Slider extends FormAssociatedSlider {

#isNonVisibleFocus = false;

constructor() {
super();

const fastSliderInternals = this as any;

const originalHandleMouseDown = fastSliderInternals.handleMouseDown;
// Called with e=null to clean up after releasing the mouse
fastSliderInternals.handleMouseDown = (e: MouseEvent | null) => {
this.#isNonVisibleFocus = true;
originalHandleMouseDown(e);
this.#isNonVisibleFocus = false;

if (e && !this.disabled && !this.readOnly) {
// Fix bug in FAST: isDragging is not set on mousedown
this.isDragging = true;
}
};

const originalHandleThumbMouseDown =
fastSliderInternals.handleThumbMouseDown;
fastSliderInternals.handleThumbMouseDown = (e: MouseEvent) => {
this.#isNonVisibleFocus = true;
originalHandleThumbMouseDown(e);
this.#isNonVisibleFocus = false;
};

const originalKeypressHandler = fastSliderInternals.keypressHandler;
fastSliderInternals.keypressHandler = (e: KeyboardEvent) => {
this._focusVisible = true;
originalKeypressHandler(e);
};
}

#registerThumbListeners() {
this.thumb.addEventListener('mouseover', this.#onMouseOver, {
passive: true,
Expand Down

0 comments on commit 09e199b

Please sign in to comment.