@lvce-editor/virtual-dom 2.14.0 → 2.16.0

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.
package/dist/index.js CHANGED
@@ -813,6 +813,11 @@ const render = (elements, eventMap = {}, newEventMap = {}) => {
813
813
  return $Root;
814
814
  };
815
815
 
816
+ const focusElement = $Element => {
817
+ $Element.focus({
818
+ preventScroll: true
819
+ });
820
+ };
816
821
  const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
817
822
  startIgnore();
818
823
  const oldLeft = $Viewlet.style.left;
@@ -864,18 +869,18 @@ const rememberFocus = ($Viewlet, dom, eventMap, uid = 0) => {
864
869
  renderInto($Viewlet, dom, eventMap);
865
870
  }
866
871
  if (isRootTree) {
867
- $Viewlet.focus();
872
+ focusElement($Viewlet);
868
873
  } else if (isTreeFocused) {
869
874
  const $Tree = $Viewlet.querySelector('[role="tree"]');
870
875
  if ($Tree) {
871
876
  // @ts-ignore
872
- $Tree.focus();
877
+ focusElement($Tree);
873
878
  }
874
879
  } else if (focused) {
875
880
  const $Focused = $Viewlet.querySelector(`[name="${focused}"]`);
876
881
  if ($Focused) {
877
882
  // @ts-ignore
878
- $Focused.focus();
883
+ focusElement($Focused);
879
884
  }
880
885
  }
881
886
  $Viewlet.style.top = oldTop;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/virtual-dom",
3
- "version": "2.14.0",
3
+ "version": "2.16.0",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "keywords": [],
@@ -5,6 +5,10 @@ import * as QueryInputs from '../QueryInputs/QueryInputs.ts'
5
5
  import * as RegisterEventListeners from '../RegisterEventListeners/RegisterEventListeners.ts'
6
6
  import * as VirtualDom from '../VirtualDom/VirtualDom.ts'
7
7
 
8
+ const focusElement = ($Element: HTMLElement): void => {
9
+ $Element.focus({ preventScroll: true })
10
+ }
11
+
8
12
  export const rememberFocus = (
9
13
  $Viewlet: HTMLElement,
10
14
  dom: any[],
@@ -66,19 +70,19 @@ export const rememberFocus = (
66
70
  }
67
71
 
68
72
  if (isRootTree) {
69
- $Viewlet.focus()
73
+ focusElement($Viewlet)
70
74
  } else if (isTreeFocused) {
71
75
  const $Tree = $Viewlet.querySelector('[role="tree"]')
72
76
  if ($Tree) {
73
77
  // @ts-ignore
74
- $Tree.focus()
78
+ focusElement($Tree)
75
79
  }
76
80
  } else if (focused) {
77
81
  const $Focused = $Viewlet.querySelector(`[name="${focused}"]`)
78
82
 
79
83
  if ($Focused) {
80
84
  // @ts-ignore
81
- $Focused.focus()
85
+ focusElement($Focused)
82
86
  }
83
87
  }
84
88