Skip to content

Commit f6cdd97

Browse files
committed
refactor: no need to prefix or suffix id generated by createElementId
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 52dae93 commit f6cdd97

File tree

8 files changed

+31
-25
lines changed

8 files changed

+31
-25
lines changed

src/components/NcActionButtonGroup/NcActionButtonGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default defineComponent({
116116
117117
setup() {
118118
return {
119-
labelId: `nc-action-button-group-${createElementId()}`,
119+
labelId: createElementId(),
120120
}
121121
},
122122

src/components/NcActionRadio/NcActionRadio.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ So that only one of each name set can be selected at the same time.
6767

6868
<script>
6969
import { useModel } from 'vue'
70-
import ActionGlobalMixin from '../../mixins/actionGlobal.js'
7170
import { createElementId } from '../../utils/createElementId.ts'
71+
import ActionGlobalMixin from '../../mixins/actionGlobal.js'
7272
7373
export default {
7474
name: 'NcActionRadio',
@@ -88,7 +88,7 @@ export default {
8888
*/
8989
id: {
9090
type: String,
91-
default: () => 'action-' + createElementId(),
91+
default: () => createElementId(),
9292
validator: id => id.trim() !== '',
9393
},
9494

src/components/NcAppNavigationItem/NcAppNavigationItem.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ import NcActionButton from '../NcActionButton/index.js'
396396
import NcLoadingIcon from '../NcLoadingIcon/index.js'
397397
import NcVNodes from '../NcVNodes/index.js'
398398
import NcAppNavigationIconCollapsible from './NcAppNavigationIconCollapsible.vue'
399-
import { useIsMobile } from '../../composables/useIsMobile/index.js'
400399
import NcInputConfirmCancel from './NcInputConfirmCancel.vue'
401-
import { t } from '../../l10n.js'
400+
import { useIsMobile } from '../../composables/useIsMobile/index.js'
402401
import { createElementId } from '../../utils/createElementId.ts'
402+
import { t } from '../../l10n.js'
403403
404404
import Pencil from 'vue-material-design-icons/Pencil.vue'
405405
import Undo from 'vue-material-design-icons/Undo.vue'
@@ -449,7 +449,7 @@ export default {
449449
*/
450450
id: {
451451
type: String,
452-
default: () => 'app-navigation-item-' + createElementId(),
452+
default: () => createElementId(),
453453
validator: id => id.trim() !== '',
454454
},
455455

src/components/NcBreadcrumb/NcBreadcrumb.vue

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Renders a button element when given no redirection props, otherwise, renders <a/
6060
</template>
6161

6262
<script>
63-
import NcActions from '../NcActions/index.js'
6463
import { createElementId } from '../../utils/createElementId.ts'
64+
import NcActions from '../NcActions/index.js'
6565
import NcButton from '../NcButton/NcButton.vue'
6666
6767
import ChevronRight from 'vue-material-design-icons/ChevronRight.vue'
@@ -162,19 +162,26 @@ export default {
162162
'dropped',
163163
'update:open',
164164
],
165+
166+
setup() {
167+
return {
168+
/**
169+
* The unique id of the breadcrumb. Necessary to append the
170+
* Actions menu to the correct crumb.
171+
*/
172+
crumbId: createElementId(),
173+
}
174+
},
175+
165176
data() {
166177
return {
167178
/**
168179
* Variable to track if we hover over the breadcrumb
169180
*/
170181
hovering: false,
171-
/**
172-
* The unique id of the breadcrumb. Necessary to append the
173-
* Actions menu to the correct crumb.
174-
*/
175-
crumbId: `crumb-id-${createElementId()}`,
176182
}
177183
},
184+
178185
computed: {
179186
/**
180187
* The attributes to pass to `router-link` or `a`

src/components/NcDateTimePicker/NcDateTimePicker.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export default ScopeComponent({
280280
281281
setup() {
282282
return {
283-
timezoneDialogHeaderId: `timezone-dialog-header-${createElementId()}`,
283+
timezoneDialogHeaderId: createElementId(),
284284
}
285285
},
286286

src/components/NcRichContenteditable/NcRichContenteditable.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ import richEditor from '../../mixins/richEditor/index.js'
290290
import Tooltip from '../../directives/Tooltip/index.js'
291291
import { emojiSearch, emojiAddRecent } from '../../functions/emoji/index.ts'
292292
import { searchProvider, getLinkWithPicker } from '../NcRichText/index.js'
293+
import { createElementId } from '../../utils/createElementId.ts'
293294
294295
import Tribute from 'tributejs/dist/tribute.esm.js'
295296
import debounce from 'debounce'
296297
import stringLength from 'string-length'
297-
import { createElementId } from '../../utils/createElementId.ts'
298298
299299
/**
300300
* Populate the list of text smiles we want to offer via Tribute.
@@ -324,7 +324,7 @@ export default {
324324
*/
325325
id: {
326326
type: String,
327-
default: () => createElementId(7),
327+
default: () => createElementId(),
328328
},
329329
330330
/**
@@ -425,11 +425,11 @@ export default {
425425
],
426426
427427
setup() {
428-
const uid = createElementId()
429428
return {
430429
// Constants
431-
labelId: `nc-rich-contenteditable-${uid}-label`,
432-
tributeId: `nc-rich-contenteditable-${uid}-tribute`,
430+
labelId: createElementId(),
431+
tributeId: createElementId(),
432+
433433
/**
434434
* Non-reactive property to store Tribute instance
435435
*
@@ -559,7 +559,7 @@ export default {
559559
},
560560
561561
initializeTribute() {
562-
const renderMenuItem = (content) => `<div id="nc-rich-contenteditable-tribute-item-${createElementId()}" class="${this.$style['tribute-item']}" role="option">${content}</div>`
562+
const renderMenuItem = (content) => `<div id="${createElementId()}" class="${this.$style['tribute-item']}" role="option">${content}</div>`
563563
564564
const tributesCollection = []
565565
tributesCollection.push({

src/components/NcSelect/NcSelect.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ import {
574574
shift,
575575
} from '@floating-ui/dom'
576576
import { h, warn } from 'vue'
577+
import { createElementId } from '../../utils/createElementId.ts'
577578
import { t } from '../../l10n.js'
578579
579580
import ChevronDown from 'vue-material-design-icons/ChevronDown.vue'
@@ -583,8 +584,6 @@ import NcEllipsisedOption from '../NcEllipsisedOption/index.js'
583584
import NcListItemIcon from '../NcListItemIcon/index.js'
584585
import NcLoadingIcon from '../NcLoadingIcon/index.js'
585586
586-
import { createElementId } from '../../utils/createElementId.ts'
587-
588587
export default {
589588
name: 'NcSelect',
590589
@@ -758,7 +757,7 @@ export default {
758757
*/
759758
inputId: {
760759
type: String,
761-
default: () => `select-input-${createElementId()}`,
760+
default: () => createElementId(),
762761
},
763762
764763
/**

src/components/NcTimezonePicker/NcTimezonePicker.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ import {
4343
getReadableTimezoneName,
4444
getSortedTimezoneList,
4545
} from './timezone.js'
46-
import getTimezoneManager from './timezoneDataProviderService.js'
4746
import { createElementId } from '../../utils/createElementId.ts'
48-
import NcSelect from '../NcSelect/index.js'
4947
import { t } from '../../l10n.js'
48+
import getTimezoneManager from './timezoneDataProviderService.js'
49+
import NcSelect from '../NcSelect/index.js'
5050
5151
export default {
5252
name: 'NcTimezonePicker',
@@ -73,7 +73,7 @@ export default {
7373
*/
7474
uid: {
7575
type: [String, Number],
76-
default: () => `tz-${createElementId()}`,
76+
default: () => createElementId(),
7777
},
7878
},
7979
emits: ['update:modelValue'],

0 commit comments

Comments
 (0)