Skip to content

Commit

Permalink
refactor(lightbox): improve z-index stacking and add stop propagation (
Browse files Browse the repository at this point in the history
  • Loading branch information
domw30 authored Dec 6, 2024
1 parent 2ee6beb commit 2aa9d76
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/chat-view-container/chat-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ export class ChatView extends React.Component<Properties, State> {
this.setState({ lightboxMedia, lightboxStartIndex, isLightboxOpen: true });
};

closeLightBox = () => {
closeLightBox = (e) => {
e?.stopPropagation?.();
this.setState({ isLightboxOpen: false });
};

Expand Down
22 changes: 19 additions & 3 deletions src/components/lightbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface LightboxProps {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
items: any[];
startingIndex?: number;
onClose?: () => void;
onClose?: (e?: React.MouseEvent) => void;
provider: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
fitWithinBox: (media: any) => any;
Expand Down Expand Up @@ -133,12 +133,28 @@ export const Lightbox = ({ items, startingIndex = 0, onClose, provider }: Lightb
onMoveNextRequest={() => setIndex(getNextItemIndex(index))}
toolbarButtons={[
!isCurrentItemGif && (
<button key='copy' onClick={copyImage} className={styles.DownloadButton} aria-label='Copy image'>
<button
key='copy'
onClick={(e) => {
e.stopPropagation();
copyImage();
}}
className={styles.DownloadButton}
aria-label='Copy image'
>
<IconCopy2 size={28} isFilled={isCopied} />
</button>
),
!isCurrentItemGif && (
<button key='download' onClick={downloadImage} className={styles.DownloadButton} aria-label='Download image'>
<button
key='download'
onClick={(e) => {
e.stopPropagation();
downloadImage();
}}
className={styles.DownloadButton}
aria-label='Download image'
>
<IconDownload2 size={28} />
</button>
),
Expand Down
11 changes: 11 additions & 0 deletions src/components/lightbox/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,23 @@
}

.ril__toolbar {
z-index: 10000;
background: none;
}

.ril__toolbarRightSide {
position: relative;
z-index: 10001;
}

.ril__outer {
z-index: 9999;
}
}
}

.DownloadButton {
z-index: 10001;
width: 40px;
height: 35px;
cursor: pointer;
Expand Down

0 comments on commit 2aa9d76

Please sign in to comment.