@lumx/react 3.8.2-alpha.0 → 3.8.2-alpha.1

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
@@ -6,8 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/core": "^3.8.2-alpha.0",
10
- "@lumx/icons": "^3.8.2-alpha.0",
9
+ "@lumx/core": "^3.8.2-alpha.1",
10
+ "@lumx/icons": "^3.8.2-alpha.1",
11
11
  "@popperjs/core": "^2.5.4",
12
12
  "body-scroll-lock": "^3.1.5",
13
13
  "classnames": "^2.3.2",
@@ -111,5 +111,5 @@
111
111
  "build:storybook": "storybook build"
112
112
  },
113
113
  "sideEffects": false,
114
- "version": "3.8.2-alpha.0"
114
+ "version": "3.8.2-alpha.1"
115
115
  }
@@ -4,7 +4,7 @@ import classNames from 'classnames';
4
4
  import { Lightbox } from '@lumx/react';
5
5
  import { ClickAwayProvider } from '@lumx/react/utils';
6
6
  import type { Comp } from '@lumx/react/utils/type';
7
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
7
+ import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
8
8
 
9
9
  import { ImageSlideshow } from './internal/ImageSlideshow';
10
10
  import { useImageLightbox } from './useImageLightbox';
@@ -32,6 +32,19 @@ const Inner: Comp<ImageLightboxProps, HTMLDivElement> = forwardRef((props, ref)
32
32
  const imageRef = React.useRef(null);
33
33
  const clickAwayChildrenRefs = React.useRef([imageRef, footerRef]);
34
34
 
35
+ const onClickAway = React.useCallback(
36
+ (evt: Event) => {
37
+ const targetElement = evt.target;
38
+ if (!(targetElement instanceof HTMLElement) || !(evt instanceof MouseEvent)) return;
39
+
40
+ // Skip click away if clicking on the scrollbar
41
+ if (targetElement.clientWidth < evt.clientX || targetElement.clientHeight < evt.clientY) return;
42
+
43
+ onClose?.();
44
+ },
45
+ [onClose],
46
+ );
47
+
35
48
  return (
36
49
  <Lightbox
37
50
  ref={ref}
@@ -43,7 +56,7 @@ const Inner: Comp<ImageLightboxProps, HTMLDivElement> = forwardRef((props, ref)
43
56
  focusElement={currentPaginationItemRef}
44
57
  {...forwardedProps}
45
58
  >
46
- <ClickAwayProvider childrenRefs={clickAwayChildrenRefs} callback={onClose}>
59
+ <ClickAwayProvider childrenRefs={clickAwayChildrenRefs} callback={onClickAway}>
47
60
  <ImageSlideshow
48
61
  activeImageIndex={activeImageIndex}
49
62
  slideGroupLabel={slideGroupLabel}
@@ -52,7 +65,7 @@ const Inner: Comp<ImageLightboxProps, HTMLDivElement> = forwardRef((props, ref)
52
65
  zoomInButtonProps={zoomInButtonProps}
53
66
  zoomOutButtonProps={zoomOutButtonProps}
54
67
  footerRef={footerRef}
55
- activeImageRef={mergeRefs(propImageRef, imageRef)}
68
+ activeImageRef={useMergeRefs(propImageRef, imageRef)}
56
69
  currentPaginationItemRef={currentPaginationItemRef}
57
70
  />
58
71
  </ClickAwayProvider>