Skip to content

Commit a7bcfac

Browse files
committed
provide open status for the lightbox - needed for android back button
1 parent 522fd61 commit a7bcfac

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

component-library/src/components/custom/BccLightbox/BccLightbox.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
1212
import BccLightboxMedia from './BccLightboxMedia.vue';
1313
import { LightboxStore } from './state';
1414
15-
const dialogRef = ref<HTMLElement | null>(null);
1615
const closeButtonRef = ref<HTMLButtonElement | null>(null);
1716
const mediaRef = ref<InstanceType<typeof BccLightboxMedia> | null>(null);
1817
@@ -110,7 +109,6 @@ onUnmounted(() => {
110109
<Teleport to="body">
111110
<div
112111
v-if="LightboxStore.state.visible && currentItem"
113-
ref="dialogRef"
114112
class="bcc-lightbox"
115113
role="dialog"
116114
aria-modal="true"

component-library/src/components/custom/BccLightbox/state.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ let scrollLockCount = 0;
1919
let activeCallbacks: Pick<LightboxOpenOptions, 'onShow' | 'onHide'> = {};
2020
let mounted = false;
2121

22-
const lightboxApi: LightboxApi = {
23-
open: openLightbox,
24-
close: closeLightbox,
25-
};
26-
2722
function lockBodyScroll() {
2823
if (scrollLockCount === 0) {
2924
document.body.style.overflow = 'hidden';
@@ -117,6 +112,13 @@ export const LightboxStore = {
117112
};
118113

119114
export function installBccLightbox(app: App) {
115+
const lightboxApi: LightboxApi = {
116+
open: openLightbox,
117+
close: closeLightbox,
118+
get isOpen() {
119+
return state.visible;
120+
},
121+
};
120122
app.provide(LIGHTBOX_KEY, lightboxApi);
121123

122124
if (mounted || typeof document === 'undefined') {

component-library/src/components/custom/BccLightbox/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export type LightboxState = {
3333
export type LightboxApi = {
3434
open: (options: LightboxOpenOptions) => void;
3535
close: () => void;
36+
readonly isOpen: boolean;
3637
};
3738

3839
export const LIGHTBOX_KEY: InjectionKey<LightboxApi> = Symbol('bcc-lightbox');

0 commit comments

Comments
 (0)