diff options
author | nfebe <fenn25.fn@gmail.com> | 2025-04-23 01:07:29 +0100 |
---|---|---|
committer | nfebe <fenn25.fn@gmail.com> | 2025-04-23 22:42:43 +0100 |
commit | 2f6c17180679fc314d5d3392ef3ce2e6cd8dd292 (patch) | |
tree | 7d2baa53737facce035857c6b7f6433b89e4683f | |
parent | f5f5a07e38e6cb629fa62935f790760df06989fd (diff) | |
download | nextcloud-server-fix/51875/allow-keyboard-input-4-share-expiration-on-chrome.tar.gz nextcloud-server-fix/51875/allow-keyboard-input-4-share-expiration-on-chrome.zip |
fix(files_sharing): Improve expiration date input change handlingfix/51875/allow-keyboard-input-4-share-expiration-on-chrome
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) }, /** |