Skip to content

Commit b83c7ea

Browse files
committed
chore: Update Gallery component to use computed hash property for id attribute
1 parent 46a8363 commit b83c7ea

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/Gallery/Gallery.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default {
2424
},
2525
computed: {
2626
hash() {
27-
const hash = this.files.map((file) => file.id).join('_');
27+
const hash = this.files.filter((_, i) => i < 3).map((file) => file.id).join('_');
2828
2929
return `${this.id}-${hash}`
3030
},
@@ -33,7 +33,7 @@ export default {
3333
this.$nextTick(() => {
3434
if (!this.lightbox) {
3535
this.lightbox = new PhotoSwipeLightbox({
36-
gallery: '#' + this.$props.id,
36+
gallery: '#' + this.hash,
3737
showHideAnimationType: 'fade',
3838
children: 'a',
3939
pswpModule: PhotoSwipe,
@@ -137,7 +137,7 @@ export default {
137137
},
138138
methods: {
139139
onOpen() {
140-
document.querySelectorAll(`#${this.hash} a`)?.[0].click();
140+
document.querySelector(`#${this.hash} a`)?.click();
141141
}
142142
}
143143
}

resources/js/fields/DetailField.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<PanelItem :index="index" :field="field">
33
<template v-slot:value>
4-
<gallery :files="files" v-if="files.length" :id="`gallery-${resource.id.value}`" resourceView="detail" />
4+
<gallery :files="files" v-if="files.length" :id="`gallery_${resource.id.value}`" resourceView="detail" />
55
<span v-else>—</span>
66
</template>
77
</PanelItem>

resources/js/fields/IndexField.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<span>
3-
<gallery :files="files" v-if="files.length" :id="`gallery-${resource.id.value}`" resourceView="index" />
3+
<gallery :files="files" v-if="files.length" :id="`gallery_${resource.id.value}`" resourceView="index" />
44
<span v-else>—</span>
55
</span>
66
</template>

0 commit comments

Comments
 (0)