vira 31.31.3 → 31.31.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,7 +6,7 @@ import { createFocusStyles } from '../../styles/focus.js';
|
|
|
6
6
|
import { noNativeFormStyles, noUserSelect, viraDisabledStyles } from '../../styles/index.js';
|
|
7
7
|
import { defineViraElement } from '../../util/define-vira-element.js';
|
|
8
8
|
import { triggerPopUpState } from '../../util/pop-up-helpers.js';
|
|
9
|
-
import { HidePopUpEvent, isInputLikeElement, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager.js';
|
|
9
|
+
import { HidePopUpEvent, isInputLikeElement, isMouseEventOnScrollbar, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager.js';
|
|
10
10
|
import { ViraMenuItem } from './vira-menu-item.element.js';
|
|
11
11
|
/**
|
|
12
12
|
* Anchor options for pop-ups.
|
|
@@ -334,7 +334,9 @@ export const ViraPopUpTrigger = defineViraElement()({
|
|
|
334
334
|
}
|
|
335
335
|
respondToClick(event);
|
|
336
336
|
}
|
|
337
|
-
else if (event.button === 0 &&
|
|
337
|
+
else if (event.button === 0 &&
|
|
338
|
+
state.showPopUpResult &&
|
|
339
|
+
!isMouseEventOnScrollbar(event)) {
|
|
338
340
|
const dropdownTrigger = host.shadowRoot.querySelector('.dropdown-trigger');
|
|
339
341
|
/**
|
|
340
342
|
* Close the menu when a mouse click originates from the pop-up area (e.g. a
|
|
@@ -11,6 +11,7 @@ import { viraShadows } from '../styles/shadows.js';
|
|
|
11
11
|
import { noUserSelect } from '../styles/user-select.js';
|
|
12
12
|
import { viraTheme } from '../styles/vira-color-theme.js';
|
|
13
13
|
import { defineViraElement } from '../util/define-vira-element.js';
|
|
14
|
+
import { isMouseEventOnScrollbar } from '../util/pop-up-manager.js';
|
|
14
15
|
import { ViraIcon } from './vira-icon.element.js';
|
|
15
16
|
const globalEventsToCloseDrawerOn = [
|
|
16
17
|
'pagehide',
|
|
@@ -225,7 +226,8 @@ export const ViraDrawer = defineViraElement()({
|
|
|
225
226
|
})}
|
|
226
227
|
${listen('mousedown', (event) => {
|
|
227
228
|
if (state.contentElement &&
|
|
228
|
-
!event.composedPath().includes(state.contentElement)
|
|
229
|
+
!event.composedPath().includes(state.contentElement) &&
|
|
230
|
+
!isMouseEventOnScrollbar(event)) {
|
|
229
231
|
close();
|
|
230
232
|
}
|
|
231
233
|
})}
|
|
@@ -9,6 +9,7 @@ import { noNativeFormStyles, noNativeSpacing } from '../styles/native-styles.js'
|
|
|
9
9
|
import { viraShadows } from '../styles/shadows.js';
|
|
10
10
|
import { viraTheme } from '../styles/vira-color-theme.js';
|
|
11
11
|
import { defineViraElement } from '../util/define-vira-element.js';
|
|
12
|
+
import { isMouseEventOnScrollbar } from '../util/pop-up-manager.js';
|
|
12
13
|
import { ViraIcon } from './vira-icon.element.js';
|
|
13
14
|
const globalEventsToCloseModalOn = [
|
|
14
15
|
'pagehide',
|
|
@@ -205,7 +206,8 @@ export const ViraModal = defineViraElement()({
|
|
|
205
206
|
${listen('mousedown', (event) => {
|
|
206
207
|
if (state.contentElement &&
|
|
207
208
|
!event.composedPath().includes(state.contentElement) &&
|
|
208
|
-
!inputs.blockLightDismissal
|
|
209
|
+
!inputs.blockLightDismissal &&
|
|
210
|
+
!isMouseEventOnScrollbar(event)) {
|
|
209
211
|
/** Background click. */
|
|
210
212
|
close();
|
|
211
213
|
}
|
|
@@ -7,6 +7,15 @@ import { type ExtractEventByType, type ExtractEventTypes, type ListenOptions, Li
|
|
|
7
7
|
* @category Internal
|
|
8
8
|
*/
|
|
9
9
|
export declare function isInputLikeElement(element: Element): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Determines if a mouse event landed on a scrollbar rather than on element content. Scrollbar
|
|
12
|
+
* interactions fire mouse events on the scrolling element itself (or on `<html>` for the page
|
|
13
|
+
* scrollbar), so an outside-click check would otherwise treat dragging a scrollbar as a click away
|
|
14
|
+
* from the pop-up and dismiss it mid-drag.
|
|
15
|
+
*
|
|
16
|
+
* @category Internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function isMouseEventOnScrollbar(event: Readonly<MouseEvent>): boolean;
|
|
10
19
|
/**
|
|
11
20
|
* A type used for representing a rectangle's position.
|
|
12
21
|
*
|
|
@@ -119,7 +128,7 @@ declare const HidePopUpEvent_base: (new (eventInitDict?: EventInit) => Event & i
|
|
|
119
128
|
readonly CAPTURING_PHASE: 1;
|
|
120
129
|
readonly AT_TARGET: 2;
|
|
121
130
|
readonly BUBBLING_PHASE: 3;
|
|
122
|
-
}, "
|
|
131
|
+
}, "NONE" | "CAPTURING_PHASE" | "AT_TARGET" | "BUBBLING_PHASE" | "prototype"> & Pick<import("typed-event-target").TypedEvent<"hide-pop-up">, "type">;
|
|
123
132
|
/**
|
|
124
133
|
* An event fired from {@link PopUpManager} when the pop up should be hidden.
|
|
125
134
|
*
|
|
@@ -139,7 +148,7 @@ declare const NavSelectEvent_base: (new (eventInitDict: {
|
|
|
139
148
|
readonly CAPTURING_PHASE: 1;
|
|
140
149
|
readonly AT_TARGET: 2;
|
|
141
150
|
readonly BUBBLING_PHASE: 3;
|
|
142
|
-
}, "
|
|
151
|
+
}, "NONE" | "CAPTURING_PHASE" | "AT_TARGET" | "BUBBLING_PHASE" | "prototype"> & Pick<import("typed-event-target").TypedCustomEvent<Coords, "nav-select">, "type">;
|
|
143
152
|
/**
|
|
144
153
|
* An event fired from {@link PopUpManager} when an individual item in the pop up has been selected
|
|
145
154
|
* by the user.
|
|
@@ -21,6 +21,31 @@ export function isInputLikeElement(element) {
|
|
|
21
21
|
element instanceof HTMLTextAreaElement ||
|
|
22
22
|
(element instanceof HTMLElement && element.isContentEditable));
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Determines if a mouse event landed on a scrollbar rather than on element content. Scrollbar
|
|
26
|
+
* interactions fire mouse events on the scrolling element itself (or on `<html>` for the page
|
|
27
|
+
* scrollbar), so an outside-click check would otherwise treat dragging a scrollbar as a click away
|
|
28
|
+
* from the pop-up and dismiss it mid-drag.
|
|
29
|
+
*
|
|
30
|
+
* @category Internal
|
|
31
|
+
*/
|
|
32
|
+
export function isMouseEventOnScrollbar(event) {
|
|
33
|
+
const target = event.composedPath()[0];
|
|
34
|
+
if (!(target instanceof Element)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
const rect = target.getBoundingClientRect();
|
|
38
|
+
/**
|
|
39
|
+
* `clientLeft` and `clientTop` are the border widths, which also include the scrollbar itself
|
|
40
|
+
* when it's rendered on the leading edge (RTL layouts).
|
|
41
|
+
*/
|
|
42
|
+
const clientLeft = rect.left + target.clientLeft;
|
|
43
|
+
const clientTop = rect.top + target.clientTop;
|
|
44
|
+
const outsideHorizontally = event.clientX < clientLeft || event.clientX >= clientLeft + target.clientWidth;
|
|
45
|
+
const outsideVertically = event.clientY < clientTop || event.clientY >= clientTop + target.clientHeight;
|
|
46
|
+
return ((outsideHorizontally && target.scrollHeight > target.clientHeight) ||
|
|
47
|
+
(outsideVertically && target.scrollWidth > target.clientWidth));
|
|
48
|
+
}
|
|
24
49
|
/**
|
|
25
50
|
* The default empty {@link PositionRect}, with all values set to 0.
|
|
26
51
|
*
|
|
@@ -98,9 +123,11 @@ export class PopUpManager {
|
|
|
98
123
|
}
|
|
99
124
|
}),
|
|
100
125
|
listenToGlobal('mousedown', (event) => {
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
126
|
+
if (
|
|
127
|
+
/** Ignore clicks that came from the pop up host itself. */
|
|
128
|
+
(this.lastRootElement &&
|
|
129
|
+
event.composedPath().includes(this.lastRootElement)) ||
|
|
130
|
+
isMouseEventOnScrollbar(event)) {
|
|
104
131
|
return;
|
|
105
132
|
}
|
|
106
133
|
this.removePopUp();
|