-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to clear DateTime field? #2358
Comments
It's a known bug currently. |
Will you consider to make a "Clear" button to clear the field? We sometimes define a field "valid_until" that allow user input empty value which is the meaning of "forever". This bug is quite bothering. |
It seems if you set it to a date field you can clear it but date time won't let you. |
Also is that it doesn't default to current date time value, only to current date value |
After clearing the datetime field did you try to click on another field or elsewhere in the background? Or did you just go to click Update Post right away? Because I just tested it again after your comment and the value go back if i click on another field or the background. And I'm on the latest nova version. |
yea it doesn't look like @jbrooksuk is on the latest version i'm currently using 2.12.0 |
I shall look at this now.
I only just released v2.12.0 😂 |
yep just sharing my version updated today @jbrooksuk |
Yes, it's actual only for DateTime, my version is 2.12.0 and bug exists |
@jbrooksuk where you able to reproduce this issue? |
Hey @jbrooksuk @davidhemphill, I spent some time debugging this issue and came up with a solution. There seem to be a few open issues on the flatpickr repository regarding this problem, but no clear solution. However, the problem can be easily overcome in Nova by applying the following changes to the <template>
<input
:disabled="disabled"
:class="{ '!cursor-not-allowed': disabled }"
+ @keyup.delete="onClear"
:value="value"
ref="datePicker"
type="text"
:placeholder="placeholder"
/>
</template>
<script>
import flatpickr from 'flatpickr'
import 'flatpickr/dist/themes/airbnb.css'
export default {
props: {
...
},
data: () => ({ flatpickr: null }),
mounted() {
this.$nextTick(() => {
this.flatpickr = flatpickr(this.$refs.datePicker, {
enableTime: this.enableTime,
enableSeconds: this.enableSeconds,
onClose: this.onChange,
onChange: this.onChange,
dateFormat: this.dateFormat,
allowInput: true,
// static: true,
time_24hr: !this.twelveHourTime,
locale: { firstDayOfWeek: this.firstDayOfWeek },
})
})
},
methods: {
onChange(event) {
this.$emit('change', this.$refs.datePicker.value)
},
+ onClear(event) {
+ if(event.target.value === '') {
+ this.flatpickr.close();
+ }
+ }
},
beforeDestroy() {
this.flatpickr.destroy()
},
}
</script>
<style scoped>
.\!cursor-not-allowed {
cursor: not-allowed !important;
}
</style> The resulting workflow is as follows:
Any chance you could verify the solution and apply the fix? Thanks in advance! |
@michielkempen this didn't work for me using Super+Del. |
However, it works if I select all and then delete, but that's only one way to delete it. |
It's doesn't works for me |
How about make a "Clear" button, no matter on calendar or under the field? And this approach should have no more arguing on deleting the text is work or not. |
What about fix? |
still not working on v3.1.0 |
There is a workaround in the meantime #2344 (comment) @dmitriytretyakov @zachgarcia1 It is working for me 🙏 |
This is still occuring |
Please fix this |
still not working on v3.2.1 |
Locking as we know this is a bug and is not yet fixed. |
Fixed via laravel/nova#907 |
I try to delete value from input and then click out of the field, system add some default value to field, how can i clear field?
The text was updated successfully, but these errors were encountered: