vira 28.19.4 → 28.19.5

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.
@@ -1,9 +1,10 @@
1
1
  import { assert } from '@augment-vir/assert';
2
+ import { walkActiveElement } from '@augment-vir/web';
2
3
  import { NavController } from 'device-navigation';
3
4
  import { classMap, css, defineElementEvent, html, listen, renderIf } from 'element-vir';
4
5
  import { createFocusStyles } from '../../styles/focus.js';
5
6
  import { noNativeFormStyles, noUserSelect, viraDisabledStyles } from '../../styles/index.js';
6
- import { HidePopUpEvent, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager.js';
7
+ import { HidePopUpEvent, isInputLikeElement, NavSelectEvent, PopUpManager, } from '../../util/pop-up-manager.js';
7
8
  import { defineViraElement } from '../define-vira-element.js';
8
9
  import { triggerPopUpState } from './pop-up-helpers.js';
9
10
  /**
@@ -285,6 +286,19 @@ export const ViraPopUpTrigger = defineViraElement()({
285
286
  ${listen('click', (event) => {
286
287
  /** Detail is 0 if it was a keyboard key (like Enter) that triggered this click. */
287
288
  if (event.detail === 0) {
289
+ let isTextActiveElement = false;
290
+ walkActiveElement(({ element }) => {
291
+ if (isInputLikeElement(element)) {
292
+ isTextActiveElement = true;
293
+ return true;
294
+ }
295
+ else {
296
+ return false;
297
+ }
298
+ });
299
+ if (isTextActiveElement) {
300
+ return;
301
+ }
288
302
  respondToClick(event);
289
303
  }
290
304
  })}
@@ -1,6 +1,12 @@
1
1
  import { type MaybePromise } from '@augment-vir/common';
2
2
  import { type Coords, type NavController } from 'device-navigation';
3
3
  import { type ExtractEventByType, type ExtractEventTypes, type ListenOptions, type RemoveListenerCallback } from 'typed-event-target';
4
+ /**
5
+ * Used to prevent pop-ups from closing when a text input is active.
6
+ *
7
+ * @category Internal
8
+ */
9
+ export declare function isInputLikeElement(element: Element): boolean;
4
10
  /**
5
11
  * A type used for representing a rectangle's position.
6
12
  *
@@ -4,6 +4,23 @@ import { findOverflowAncestor } from '@augment-vir/web';
4
4
  import { NavActivateEvent, NavDirection } from 'device-navigation';
5
5
  import { listenToPageActivation } from 'page-active';
6
6
  import { ListenTarget, defineTypedCustomEvent, defineTypedEvent, listenToGlobal, } from 'typed-event-target';
7
+ /**
8
+ * Used to prevent pop-ups from closing when a text input is active.
9
+ *
10
+ * @category Internal
11
+ */
12
+ export function isInputLikeElement(element) {
13
+ return ((element instanceof HTMLInputElement &&
14
+ (element.type === 'text' ||
15
+ element.type === 'search' ||
16
+ element.type === 'email' ||
17
+ element.type === 'url' ||
18
+ element.type === 'tel' ||
19
+ element.type === 'password' ||
20
+ element.type === 'number')) ||
21
+ element instanceof HTMLTextAreaElement ||
22
+ (element instanceof HTMLElement && element.isContentEditable));
23
+ }
7
24
  /**
8
25
  * The default empty {@link PositionRect}, with all values set to 0.
9
26
  *
@@ -59,6 +76,10 @@ export class PopUpManager {
59
76
  }
60
77
  }),
61
78
  this.navController.listen(NavActivateEvent, (event) => {
79
+ const target = event.composedPath()[0];
80
+ if (target instanceof Element && isInputLikeElement(target)) {
81
+ return;
82
+ }
62
83
  if (event.detail.success) {
63
84
  this.listenTarget.dispatch(new NavSelectEvent({ detail: event.detail.coords }));
64
85
  this.navController.currentNavEntry?.entry.focus(true);
@@ -81,17 +102,7 @@ export class PopUpManager {
81
102
  }
82
103
  else if (this.options.supportNavigation) {
83
104
  const target = event.composedPath()[0];
84
- const isTextInput = (target instanceof HTMLInputElement &&
85
- (target.type === 'text' ||
86
- target.type === 'search' ||
87
- target.type === 'email' ||
88
- target.type === 'url' ||
89
- target.type === 'tel' ||
90
- target.type === 'password' ||
91
- target.type === 'number')) ||
92
- target instanceof HTMLTextAreaElement ||
93
- (target instanceof HTMLElement && target.isContentEditable);
94
- if (isTextInput) {
105
+ if (target instanceof Element && isInputLikeElement(target)) {
95
106
  return;
96
107
  }
97
108
  if (keyCode === 'ArrowDown') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "28.19.4",
3
+ "version": "28.19.5",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",
@@ -38,9 +38,9 @@
38
38
  "test:docs": "virmator docs check"
39
39
  },
40
40
  "dependencies": {
41
- "@augment-vir/assert": "^31.57.5",
42
- "@augment-vir/common": "^31.57.5",
43
- "@augment-vir/web": "^31.57.5",
41
+ "@augment-vir/assert": "^31.58.0",
42
+ "@augment-vir/common": "^31.58.0",
43
+ "@augment-vir/web": "^31.58.0",
44
44
  "colorjs.io": "^0.6.0",
45
45
  "date-vir": "^8.1.0",
46
46
  "device-navigation": "^4.5.5",
@@ -52,7 +52,7 @@
52
52
  "typed-event-target": "^4.1.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@augment-vir/test": "^31.57.5",
55
+ "@augment-vir/test": "^31.58.0",
56
56
  "@web/dev-server-esbuild": "^1.0.4",
57
57
  "@web/test-runner": "^0.20.2",
58
58
  "@web/test-runner-commands": "^0.9.0",
@@ -62,7 +62,7 @@
62
62
  "istanbul-smart-text-reporter": "^1.1.5",
63
63
  "markdown-code-example-inserter": "^3.0.3",
64
64
  "theme-vir": "^28.17.0",
65
- "typedoc": "^0.28.15",
65
+ "typedoc": "^0.28.16",
66
66
  "typescript": "5.9.3",
67
67
  "vite": "^7.3.1",
68
68
  "vite-tsconfig-paths": "^6.0.4"