Skip to content

Commit 536b81a

Browse files
nfebebackportbot[bot]
authored andcommitted
fix(files_sharing): Improve expiration date input change handling
If the time picker component is emitting a Date object already, then there is redundant call of `new Date(new Date())` and therefore introduces subtle bugs, for example on chrome users could not enter expiration date with keyboard. - Use @update:model-value instead of @change/@input for more reliable date updates - Ensure null and invalid dates are handled correctly in onExpirationChange - Validate date input before updating defaultExpirationDateEnabled Resolves : #51875 Signed-off-by: nfebe <[email protected]> [skip ci]
1 parent c05d7b9 commit 536b81a

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

apps/files_sharing/src/components/SharingEntryLink.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@
101101
type="date"
102102
:min="dateTomorrow"
103103
:max="maxExpirationDateEnforced"
104-
@change="expirationDateChanged($event)">
104+
@update:model-value="onExpirationChange"
105+
@change="expirationDateChanged">
105106
<template #icon>
106107
<IconCalendarBlank :size="20" />
107108
</template>
@@ -858,9 +859,9 @@ export default {
858859
},
859860
860861
expirationDateChanged(event) {
861-
const date = event.target.value
862-
this.onExpirationChange(date)
863-
this.defaultExpirationDateEnabled = !!date
862+
const value = event?.target?.value
863+
const isValid = !!value && !isNaN(new Date(value).getTime())
864+
this.defaultExpirationDateEnabled = isValid
864865
},
865866
866867
/**

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,13 @@ export default {
234234
* @param {Date} date
235235
*/
236236
onExpirationChange(date) {
237-
const formattedDate = date ? this.formatDateToString(new Date(date)) : ''
238-
this.share.expireDate = formattedDate
237+
if (!date) {
238+
this.share.expireDate = null
239+
this.$set(this.share, 'expireDate', null)
240+
return
241+
}
242+
const parsedDate = (date instanceof Date) ? date : new Date(date)
243+
this.share.expireDate = this.formatDateToString(parsedDate)
239244
},
240245

241246
/**

0 commit comments

Comments
 (0)