Skip to content

Commit ba2b7d0

Browse files
authored
fix(ui5-slider): fire uphandler when mouse leaves the window (#12192)
FIXES: #11460
1 parent 5af304b commit ba2b7d0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

packages/main/src/SliderBase.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ abstract class SliderBase extends UI5Element {
169169
_resizeHandler: ResizeObserverCallback;
170170
_moveHandler: (e: TouchEvent | MouseEvent) => void;
171171
_upHandler: (e: TouchEvent | MouseEvent) => void;
172+
_windowMouseoutHandler: (e: MouseEvent) => void;
172173
_stateStorage: StateStorage;
173174
notResized = false;
174175
_isUserInteraction = false;
@@ -189,6 +190,11 @@ abstract class SliderBase extends UI5Element {
189190
this._resizeHandler = this._handleResize.bind(this);
190191
this._moveHandler = this._handleMove.bind(this);
191192
this._upHandler = this._handleUp.bind(this);
193+
this._windowMouseoutHandler = (e: MouseEvent) => {
194+
if (e.relatedTarget === document.documentElement) {
195+
this.handleUpBase();
196+
}
197+
};
192198

193199
this._stateStorage = {
194200
step: undefined,
@@ -430,6 +436,7 @@ abstract class SliderBase extends UI5Element {
430436

431437
window.addEventListener("mouseup", this._upHandler);
432438
window.addEventListener("touchend", this._upHandler);
439+
window.addEventListener("mouseout", this._windowMouseoutHandler);
433440
// Only allow one type of move event to be listened to (the first one registered after the down event)
434441
if (supportsTouch() && e instanceof TouchEvent) {
435442
window.addEventListener("touchmove", this._moveHandler);
@@ -463,6 +470,7 @@ abstract class SliderBase extends UI5Element {
463470
handleUpBase() {
464471
window.removeEventListener("mouseup", this._upHandler);
465472
window.removeEventListener("touchend", this._upHandler);
473+
window.removeEventListener("mouseout", this._windowMouseoutHandler);
466474
// Only one of the following was attached, but it's ok to remove both as there is no error
467475
window.removeEventListener("mousemove", this._moveHandler);
468476
window.removeEventListener("touchmove", this._moveHandler);

0 commit comments

Comments
 (0)