@lumx/react 3.6.7-alpha.4 → 3.6.7-alpha.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.
package/index.js CHANGED
@@ -2680,7 +2680,6 @@ function getFocusableElements(element) {
2680
2680
  */
2681
2681
  function getFirstAndLastFocusable(parentElement) {
2682
2682
  const focusableElements = getFocusableElements(parentElement);
2683
- console.log('focusableElements', focusableElements);
2684
2683
 
2685
2684
  // First non disabled element.
2686
2685
  const first = focusableElements[0];
@@ -2724,26 +2723,21 @@ function useFocusTrap(focusZoneElement, focusElement) {
2724
2723
  return;
2725
2724
  }
2726
2725
  const focusable = getFirstAndLastFocusable(focusZoneElement);
2727
- console.log('data', {
2728
- focusable,
2729
- activeElement: document.activeElement,
2730
- endOfFocusZone: !evt.shiftKey && document.activeElement === focusable.last,
2731
- isInFocusZone: focusZoneElement.contains(document.activeElement)
2732
- });
2733
2726
 
2734
2727
  // Prevent focus switch if no focusable available.
2735
2728
  if (!focusable.first) {
2736
2729
  evt.preventDefault();
2737
2730
  return;
2738
2731
  }
2732
+ const activeElement = focusZoneElement.shadowRoot ? focusZoneElement.shadowRoot.activeElement : document.activeElement;
2733
+ console.log('active', activeElement);
2739
2734
  if (
2740
2735
  // No previous focus
2741
- !document.activeElement ||
2736
+ !activeElement ||
2742
2737
  // Previous focus is at the end of the focus zone.
2743
- !evt.shiftKey && document.activeElement === focusable.last ||
2738
+ !evt.shiftKey && activeElement === focusable.last ||
2744
2739
  // Previous focus is outside the focus zone
2745
- !focusZoneElement.contains(document.activeElement)) {
2746
- console.log('focus first');
2740
+ !focusZoneElement.contains(activeElement)) {
2747
2741
  focusable.first.focus();
2748
2742
  evt.preventDefault();
2749
2743
  return;
@@ -2752,7 +2746,7 @@ function useFocusTrap(focusZoneElement, focusElement) {
2752
2746
  // Focus order reversed
2753
2747
  evt.shiftKey &&
2754
2748
  // Previous focus is at the start of the focus zone.
2755
- document.activeElement === focusable.first) {
2749
+ activeElement === focusable.first) {
2756
2750
  focusable.last.focus();
2757
2751
  evt.preventDefault();
2758
2752
  }