diff options
author | nfebe <fenn25.fn@gmail.com> | 2025-04-23 01:07:29 +0100 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-04-24 12:25:47 +0200 |
commit | 3c73f3fcae70c399bafb132885e0768019ee5847 (patch) | |
tree | 95e9c90e034b66809e88aa66a0c526a6953275d6 | |
parent | 0567332af1cf3d72f91b70755b8143aac6338143 (diff) | |
download | nextcloud-server-3c73f3fcae70c399bafb132885e0768019ee5847.tar.gz nextcloud-server-3c73f3fcae70c399bafb132885e0768019ee5847.zip |
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>
-rw-r--r-- | apps/files_sharing/src/components/SharingEntryLink.vue | 9 | ||||
-rw-r--r-- | apps/files_sharing/src/mixins/SharesMixin.js | 9 |
2 files changed, 12 insertions, 6 deletions
diff --git a/apps/files_sharing/src/components/SharingEntryLink.vue b/apps/files_sharing/src/components/SharingEntryLink.vue index 2c19afd1dca..781626a1ec9 100644 --- a/apps/files_sharing/src/components/SharingEntryLink.vue +++ b/apps/files_sharing/src/components/SharingEntryLink.vue @@ -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 }, /** diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js index 7d0d0dbb59b..c5bad91314e 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -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) }, /** |