Skip to content
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

[DatePicker]: Invalid valueState on focus out of empty input #8005

Closed
1 task done
holgerrath opened this issue Dec 14, 2023 · 1 comment · Fixed by #8133
Closed
1 task done

[DatePicker]: Invalid valueState on focus out of empty input #8005

holgerrath opened this issue Dec 14, 2023 · 1 comment · Fixed by #8133
Assignees
Labels
bug This issue is a bug in the code Medium Prio TOPIC B

Comments

@holgerrath
Copy link

Bug Description

When valueState property of a DatePicker is set to Error and the date input field is cleared and left, the valueState changes to None.

Affected Component

DatePicker

Expected Behaviour

When valueState property of a DatePicker is set to Error, it should keep this state independent of the internal input value.
The valueState property of a DatePicker should only be changed in context of the use case, similar to other components like Input.

Isolated Example

No response

Steps to Reproduce

  1. https://sap.github.io/ui5-webcomponents/playground/?path=/story/main-datepicker--state
  2. set valueState property to Error
  3. focus input field
  4. remove date value
  5. focus out of the input field

Log Output, Stack Trace or Screenshots

No response

Priority

Medium

UI5 Web Components Version

1.20.0

Browser

Chrome

Operating System

Mac

Additional Context

Issue is caused by _updateValueState function, because _checkValueValidity returns true for empty input value:

_checkValueValidity(value: string): boolean {
  if (value === "") {
    return true;
  }
  return this.isValid(value) && this.isInValidRange(value);
}

_updateValueState() {
  const isValid = this._checkValueValidity(this.value);
  if (isValid && this.valueState === ValueState.Error) { // If not valid - always set Error regardless of the current value state
    this.valueState = ValueState.None;
  } else if (!isValid) { // However if valid, change only Error (but not the others) to None
    this.valueState = ValueState.Error;
  }
}

Organization

No response

Declaration

  • I’m not disclosing any internal or sensitive information.
@holgerrath holgerrath added the bug This issue is a bug in the code label Dec 14, 2023
@petyabegovska
Copy link
Collaborator

#7444
#6993

@nnaydenow nnaydenow added this to New Issues in Maintenance - Topic B via automation Jan 3, 2024
@hinzzx hinzzx self-assigned this Jan 3, 2024
@hinzzx hinzzx moved this from New Issues to In Progress in Maintenance - Topic B Jan 18, 2024
Maintenance - Topic B automation moved this from In Progress to Completed Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug in the code Medium Prio TOPIC B
Projects
Status: Completed
Development

Successfully merging a pull request may close this issue.

4 participants