Skip to content

Commit 2fc90a3

Browse files
authored
Merge pull request #14 from swoga/fix-unique-ids
fix: use uuid to generate ids
2 parents 16ae6a8 + a2b4007 commit 2fc90a3

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,9 @@
5858
"typescript": "~3.9.3",
5959
"vue": "^3.0.0"
6060
},
61-
"private": false
61+
"private": false,
62+
"dependencies": {
63+
"@types/uuid": "^8.3.0",
64+
"uuid": "^8.3.2"
65+
}
6266
}

src/components/VueCollapsiblePanel.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
</template>
5050

5151
<script lang="ts">
52+
import { v4 as uuid } from 'uuid'
5253
import {
5354
computed,
5455
defineComponent,
@@ -70,7 +71,7 @@ export default defineComponent({
7071
},
7172
},
7273
setup(props, context) {
73-
const idPanel = `panel-${Date.now()}`
74+
const idPanel = `panel-${uuid()}`
7475
const panelRef = ref<HTMLElement>()
7576
const bodyRef = ref<HTMLElement>()
7677
const bodyContentRef = ref<HTMLElement>()
@@ -83,7 +84,7 @@ export default defineComponent({
8384
const body = computed(
8485
() => ({
8586
hasContent: context.slots.content && (context.slots.content()[0].children as VNodeArrayChildren).length > 0,
86-
dataKey: Date.now(),
87+
dataKey: uuid(),
8788
}),
8889
)
8990

src/components/VueCollapsiblePanelGroup.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</template>
1010

1111
<script lang="ts">
12+
import { v4 as uuid } from 'uuid'
1213
import {
1314
defineComponent,
1415
ref,
@@ -29,7 +30,7 @@ export default defineComponent({
2930
},
3031
},
3132
setup(props) {
32-
const idGroup = ref(`group-${Date.now()}`)
33+
const idGroup = ref(`group-${uuid()}`)
3334
const { setGroupAccordionStatus } = useCollapsiblePanelStore()
3435
const cssColorVars = {
3536
'--base-color': props.baseColor,

yarn.lock

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,6 +1075,11 @@
10751075
dependencies:
10761076
source-map "^0.6.1"
10771077

1078+
"@types/uuid@^8.3.0":
1079+
version "8.3.0"
1080+
resolved "https://registry.yarnpkg.com/@types/uuid/-/uuid-8.3.0.tgz#215c231dff736d5ba92410e6d602050cce7e273f"
1081+
integrity sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==
1082+
10781083
"@types/webpack-dev-server@^3.11.0":
10791084
version "3.11.2"
10801085
resolved "https://registry.yarnpkg.com/@types/webpack-dev-server/-/webpack-dev-server-3.11.2.tgz#73915a7d9e0a9b5e010a2388a46f68ab3f770ef8"
@@ -9261,6 +9266,11 @@ uuid@^3.3.2, uuid@^3.4.0:
92619266
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
92629267
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
92639268

9269+
uuid@^8.3.2:
9270+
version "8.3.2"
9271+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
9272+
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
9273+
92649274
v8-compile-cache@^2.0.3:
92659275
version "2.3.0"
92669276
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"

0 commit comments

Comments
 (0)