mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 10:23:32 +00:00
DatePicker: Fix bug where switch from input to selection clears date text
This commit is contained in:
parent
029ed7e4c2
commit
1d92d29649
1 changed files with 7 additions and 2 deletions
|
@ -464,13 +464,14 @@ export component DatePickerBase {
|
|||
|
||||
changed selection-mode => {
|
||||
// check switch from input mode if input is valid
|
||||
if root.ok-enabled() {
|
||||
if root.selection-mode && root.current-input-valid() {
|
||||
root.current-date = root.input-as-date();
|
||||
root.display-date = root.current-date;
|
||||
}
|
||||
}
|
||||
|
||||
pure public function ok-enabled() -> bool {
|
||||
root.selection-mode || SlintInternal.valid_date(root.current-input, root.input-format)
|
||||
root.selection-mode || root.current-input-valid()
|
||||
}
|
||||
|
||||
public function get-current-date() -> Date {
|
||||
|
@ -481,6 +482,10 @@ export component DatePickerBase {
|
|||
root.input-as-date()
|
||||
}
|
||||
|
||||
pure function current-input-valid() -> bool {
|
||||
SlintInternal.valid_date(root.current-input, root.input-format)
|
||||
}
|
||||
|
||||
pure function input-as-date() -> Date {
|
||||
|
||||
{ day: root.input-formatted[0], month: root.input-formatted[1], year: root.input-formatted[2] }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue