@lumx/react 3.6.7-alpha.2 → 3.6.7-alpha.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.
package/package.json CHANGED
@@ -7,8 +7,8 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@juggle/resize-observer": "^3.2.0",
10
- "@lumx/core": "^3.6.7-alpha.2",
11
- "@lumx/icons": "^3.6.7-alpha.2",
10
+ "@lumx/core": "^3.6.7-alpha.4",
11
+ "@lumx/icons": "^3.6.7-alpha.4",
12
12
  "@popperjs/core": "^2.5.4",
13
13
  "body-scroll-lock": "^3.1.5",
14
14
  "classnames": "^2.3.2",
@@ -112,5 +112,5 @@
112
112
  "build:storybook": "storybook build"
113
113
  },
114
114
  "sideEffects": false,
115
- "version": "3.6.7-alpha.2"
115
+ "version": "3.6.7-alpha.4"
116
116
  }
@@ -33,6 +33,12 @@ export function useFocusTrap(focusZoneElement: HTMLElement | Falsy, focusElement
33
33
  return;
34
34
  }
35
35
  const focusable = getFirstAndLastFocusable(focusZoneElement);
36
+ console.log('data', {
37
+ focusable,
38
+ activeElement: document.activeElement,
39
+ endOfFocusZone: !evt.shiftKey && document.activeElement === focusable.last,
40
+ isInFocusZone: focusZoneElement.contains(document.activeElement),
41
+ });
36
42
 
37
43
  // Prevent focus switch if no focusable available.
38
44
  if (!focusable.first) {
@@ -48,6 +54,7 @@ export function useFocusTrap(focusZoneElement: HTMLElement | Falsy, focusElement
48
54
  // Previous focus is outside the focus zone
49
55
  !focusZoneElement.contains(document.activeElement)
50
56
  ) {
57
+ console.log('focus first');
51
58
  focusable.first.focus();
52
59
  evt.preventDefault();
53
60
  return;
@@ -8,6 +8,7 @@ import { getFocusableElements } from './getFocusableElements';
8
8
  */
9
9
  export function getFirstAndLastFocusable(parentElement: HTMLElement) {
10
10
  const focusableElements = getFocusableElements(parentElement);
11
+ console.log('focusableElements', focusableElements);
11
12
 
12
13
  // First non disabled element.
13
14
  const first = focusableElements[0];
@@ -3,7 +3,9 @@ import { DISABLED_SELECTOR, TABBABLE_ELEMENTS_SELECTOR } from './constants';
3
3
  const isNotDisabled = (element: HTMLElement) => !element.matches(DISABLED_SELECTOR);
4
4
 
5
5
  export function getFocusableElements(element: HTMLElement): HTMLElement[] {
6
- const focusableElements = element.shadowRoot ? getFocusableElements(element.shadowRoot) : Array.from(element.querySelectorAll<HTMLElement>(TABBABLE_ELEMENTS_SELECTOR)).filter(isNotDisabled);
6
+ const focusableElements = element.shadowRoot
7
+ ? getFocusableElements(element.shadowRoot)
8
+ : Array.from(element.querySelectorAll<HTMLElement>(TABBABLE_ELEMENTS_SELECTOR)).filter(isNotDisabled);
7
9
 
8
10
  return focusableElements;
9
11
  }