Skip to content

Commit

Permalink
chore: Update Gallery component with computed hash property
Browse files Browse the repository at this point in the history
The Gallery component has been updated to include a computed property called `hash`. This property generates a unique hash based on the `id` and `files` array, which is used to set the `id` attribute of the component's root element. This change ensures that the `id` remains unique and avoids potential conflicts with other elements on the page.
  • Loading branch information
ferdiunal committed Jul 11, 2024
1 parent 4366838 commit 46a8363
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions resources/js/components/Gallery/Gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ export default {
lightbox: null,
}
},
computed: {
hash() {
const hash = this.files.map((file) => file.id).join('_');
return `${this.id}-${hash}`
},
},
mounted() {
this.$nextTick(() => {
if (!this.lightbox) {
Expand Down Expand Up @@ -130,13 +137,13 @@ export default {
},
methods: {
onOpen() {
document.querySelectorAll(`#${this.id} a`)?.[0].click();
document.querySelectorAll(`#${this.hash} a`)?.[0].click();
}
}
}
</script>
<template>
<div :id="id" class="ln-flex ln-items-center ln-group" @click.prevent.stop="onOpen">
<div :id="hash" class="ln-flex ln-items-center ln-group" @click.prevent.stop="onOpen">
<div class="ln-flex ln-overflow-hidden" :class="{
'-ln-space-x-3': resourceView === 'index',
'-ln-space-x-5': resourceView === 'detail'
Expand Down

0 comments on commit 46a8363

Please sign in to comment.