@ewc-lib/ewc-popovers 2.0.2-beta → 2.0.3-beta

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.
@@ -14,7 +14,7 @@ export default class Element extends HTMLElement {
14
14
 
15
15
  connectedCallback(ignoreCheck) {
16
16
  if(this.#isInitialized) { return } else { this.#isInitialized=true }
17
- this.setAttribute("ewc-version", "2.0.2-beta") // please always keep in sync with version in package.json
17
+ this.setAttribute("ewc-version", "2.0.3-beta") // please always keep in sync with version in package.json
18
18
  if(ignoreCheck || this.childElementCount===2) {
19
19
  // please see also comment in html.js
20
20
 
@@ -67,26 +67,25 @@ export default class Element extends Popover {
67
67
  this.shadowRoot.querySelector(".ewc-popover__container").addEventListener(
68
68
  "keydown",
69
69
  (e) => {
70
- handle(
71
- "ArrowDown",
72
- (e) => e.nextElementSibling,
73
- (e) => e.parentNode.firstElementChild,
74
- );
75
- handle(
76
- "ArrowUp",
77
- (e) => e.previousElementSibling,
78
- (e) => e.parentNode.lastElementChild,
79
- );
80
-
81
- function handle(key, direction, direction2) {
82
- if (e.key === key) {
83
- e.preventDefault();
84
- const el = direction(e.target.closest("li"));
85
- if (el) {
86
- el.focus();
87
- } else {
88
- direction2(e.target.closest("li")).focus();
89
- }
70
+ if(e.key==="ArrowDown" || (e.key==="Tab" && !e.shiftKey)) {
71
+ handle(
72
+ (e) => e.nextElementSibling,
73
+ (e) => e.parentNode.firstElementChild,
74
+ );
75
+ }
76
+ if(e.key==="ArrowUp" || (e.key==="Tab" && e.shiftKey)) {
77
+ handle(
78
+ (e) => e.previousElementSibling,
79
+ (e) => e.parentNode.lastElementChild,
80
+ );
81
+ }
82
+ function handle(directionNext, wrapTo) {
83
+ e.preventDefault();
84
+ const el = directionNext(e.target.closest("li"));
85
+ if (el) {
86
+ el.focus();
87
+ } else {
88
+ wrapTo(e.target.closest("li")).focus();
90
89
  }
91
90
  }
92
91
  },
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@ewc-lib/ewc-popovers",
3
3
  "description": "Monorepo for EWCL popover WebComponents",
4
4
  "//": "please always keep version in sync with version info in the sourcecode",
5
- "version": "2.0.2-beta",
5
+ "version": "2.0.3-beta",
6
6
  "workspaces": [
7
7
  "ewc-popover",
8
8
  "ewc-popover-sharing"
package/readme.md CHANGED
@@ -106,4 +106,7 @@ Before the 2 popover components were grouped together into this monorepo, they e
106
106
  - adapt tests
107
107
 
108
108
  - 2.0.2-beta
109
- - version info
109
+ - version info
110
+
111
+ - 2.0.3-beta
112
+ - focus wrap for tab key