mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
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 : https://github.com/nextcloud/server/issues/51875 Signed-off-by: nfebe <fenn25.fn@gmail.com>
This commit is contained in:
parent
0567332af1
commit
3c73f3fcae
2 changed files with 12 additions and 6 deletions
|
|
@ -108,7 +108,8 @@
|
|||
type="date"
|
||||
:min="dateTomorrow"
|
||||
:max="maxExpirationDateEnforced"
|
||||
@change="expirationDateChanged($event)">
|
||||
@update:model-value="onExpirationChange"
|
||||
@change="expirationDateChanged">
|
||||
<template #icon>
|
||||
<IconCalendarBlank :size="20" />
|
||||
</template>
|
||||
|
|
@ -874,9 +875,9 @@ export default {
|
|||
},
|
||||
|
||||
expirationDateChanged(event) {
|
||||
const date = event.target.value
|
||||
this.onExpirationChange(date)
|
||||
this.defaultExpirationDateEnabled = !!date
|
||||
const value = event?.target?.value
|
||||
const isValid = !!value && !isNaN(new Date(value).getTime())
|
||||
this.defaultExpirationDateEnabled = isValid
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -234,8 +234,13 @@ export default {
|
|||
* @param {Date} date
|
||||
*/
|
||||
onExpirationChange(date) {
|
||||
const formattedDate = date ? this.formatDateToString(new Date(date)) : ''
|
||||
this.share.expireDate = formattedDate
|
||||
if (!date) {
|
||||
this.share.expireDate = null
|
||||
this.$set(this.share, 'expireDate', null)
|
||||
return
|
||||
}
|
||||
const parsedDate = (date instanceof Date) ? date : new Date(date)
|
||||
this.share.expireDate = this.formatDateToString(parsedDate)
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue