Skip to content

Commit 17819d5

Browse files
authored
Merge pull request #7286 from nextcloud-libraries/backport/input-placeholders
[stable8] fix(NcInputField, NcTextareaField): remove placeholder on Nextcloud 32+
2 parents 1a8601c + 281fac1 commit 17819d5

File tree

6 files changed

+34
-3
lines changed

6 files changed

+34
-3
lines changed

src/components/NcInputField/NcInputField.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import GenRandomId from '../../utils/GenRandomId.js'
101101
import AlertCircle from 'vue-material-design-icons/AlertCircleOutline.vue'
102102
import Check from 'vue-material-design-icons/Check.vue'
103103
import { useModelMigration } from '../../composables/useModelMigration.ts'
104+
import { isLegacy32 } from '../../utils/legacy.ts'
104105
105106
export default {
106107
name: 'NcInputField',
@@ -297,7 +298,13 @@ export default {
297298
},
298299
299300
computedPlaceholder() {
300-
return this.hasPlaceholder ? this.placeholder : this.label
301+
if (this.hasPlaceholder) {
302+
return this.placeholder
303+
}
304+
if (isLegacy32) {
305+
return this.label
306+
}
307+
return undefined
301308
},
302309
303310
isValidLabel() {

src/components/NcTextArea/NcTextArea.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ import GenRandomId from '../../utils/GenRandomId.js'
135135
import AlertCircle from 'vue-material-design-icons/AlertCircleOutline.vue'
136136
import Check from 'vue-material-design-icons/Check.vue'
137137
import { useModelMigration } from '../../composables/useModelMigration.ts'
138+
import { isLegacy32 } from '../../utils/legacy.ts'
138139
139140
export default {
140141
name: 'NcTextArea',
@@ -288,7 +289,13 @@ export default {
288289
},
289290
290291
computedPlaceholder() {
291-
return this.hasPlaceholder ? this.placeholder : this.label
292+
if (this.hasPlaceholder) {
293+
return this.placeholder
294+
}
295+
if (isLegacy32) {
296+
return this.label
297+
}
298+
return undefined
292299
},
293300
294301
isValidLabel() {

src/globals.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,10 @@ declare global {
2222
_nc_contacts_menu_hooks: { [id: string]: ContactsMenuAction }
2323
// eslint-disable-next-line @typescript-eslint/no-explicit-any
2424
OCP: any
25+
OC: {
26+
config: {
27+
version: string
28+
}
29+
}
2530
}
2631
}

src/utils/legacy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
export const isLegacy32 = Number.parseInt(window.OC?.config.version.split('.')[0] ?? '0') < 32

styleguide/global.requires.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ window.OC = {
100100
isUserAdmin() {
101101
return true
102102
},
103-
config: {},
103+
config: {
104+
version: '31.0.0',
105+
},
104106
Util: {
105107
/**
106108
* Compare two strings to provide a natural sort

tests/OC.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export default {
2323
},
2424
},
2525

26+
config: {
27+
version: '31.0.0',
28+
},
29+
2630
coreApps: [
2731
'',
2832
'admin',

0 commit comments

Comments
 (0)