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

Input-date-picker displays incorrect value if out-of-range #9282

Closed
2 of 6 tasks
nwhittaker opened this issue May 7, 2024 · 5 comments
Closed
2 of 6 tasks

Input-date-picker displays incorrect value if out-of-range #9282

nwhittaker opened this issue May 7, 2024 · 5 comments
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. ArcGIS Field Apps Issues logged by ArcGIS Field Apps team members. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. calcite-components Issues specific to the @esri/calcite-components package. estimate - 3 A day or two of work, likely requires updates to tests. future breaking change Issues and pull requests with deprecation(s), requires a breaking change in a future milestone. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - high Issue should be addressed in the current milestone, impacts component or core functionality

Comments

@nwhittaker
Copy link
Contributor

nwhittaker commented May 7, 2024

Check existing issues

Actual Behavior

An input-date-picker pre-populated with an out-of-range value displays the closest in-range value instead of the actual value. The value prop contains the out-of-range value. The out-of-range state is never reflected in the input's validity and does not block form submissions.

Expected Behavior

The input displays the out-of-range value with a rangeOverflow or rangeUnderflow validity. Opening the picker should default the calendar selection to the closest in-range value. This should match how native date-pickers handle the same scenario.

Reproduction Sample

https://codepen.io/nwhittaker-esri/pen/oNRvGqm

Reproduction Steps

  1. Visit the sample
  2. See the displayed value matches the input's min instead of its value attribute
  3. Click the submit button and see a success alert instead of a validation message

Reproduction Version

2.8.0

Relevant Info

No response

Regression?

No response

Priority impact

impact - p2 - want for an upcoming milestone

Impact

Field Maps allows users to edit meta data about form controls. As the meta data changes, the validity of a value can change. In those cases, we want the user to be able to identify the invalid data and correct it. For a date field that has become out-of-range, it can be confusing to see it marked as invalid but populated with an in-range value.

Calcite package

  • @esri/calcite-components
  • @esri/calcite-components-angular
  • @esri/calcite-components-react
  • @esri/calcite-design-tokens
  • @esri/eslint-plugin-calcite-components

Esri team

ArcGIS Field Apps

@nwhittaker nwhittaker added bug Bug reports for broken functionality. Issues should include a reproduction of the bug. 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels May 7, 2024
@github-actions github-actions bot added ArcGIS Field Apps Issues logged by ArcGIS Field Apps team members. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone calcite-components Issues specific to the @esri/calcite-components package. labels May 7, 2024
@geospatialem geospatialem added p - high Issue should be addressed in the current milestone, impacts component or core functionality estimate - 3 A day or two of work, likely requires updates to tests. labels May 9, 2024
@geospatialem geospatialem added 1 - assigned Issues that are assigned to a sprint and a team member. and removed 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels May 9, 2024
@jcfranco jcfranco added 2 - in development Issues that are actively being worked on. and removed 1 - assigned Issues that are assigned to a sprint and a team member. labels May 18, 2024
benelan added a commit that referenced this issue Jun 25, 2024
…or min/max constraints (#9677)

**Related Issue:** #8065, #9282

## Summary

- Add `min` and `mix` properties to `calcite-input-time-picker`

- Add form validation support for `min` and `max` constraints to
`calcite-input-time-picker` and `calcite-input-date-picker`
@jcfranco jcfranco added the breaking change Issues and pull requests with code changes that are not backwards compatible. label Jul 30, 2024
benelan added a commit that referenced this issue Jul 30, 2024
**Related Issue:** #9282

## Summary

Ensure the initial value is within the min/max range. This is in line
with the existing behavior, but it is not ideal.

The plan is to stop automatically changing the value to the min/max when
it is out of range, and rely on form constraint validation instead.
However, doing so would be a breaking change, so it's on hold until v3.

## Verification notes

The behavior after this is installed will look the same as the [repro
sample](https://codepen.io/benelan/pen/VwOGwZy). The key is to check the
value of the component in the form submission callback:

```js
form.onsubmit = (event) => {
  console.log(event.target.elements["date-picker"].value);
  ...
}
```

Here is an [updated repro
sample](https://codepen.io/benelan/pen/dyBNVMx?editors=1111).
@benelan benelan added the 3 - installed Issues that have been merged to master branch and are ready for final confirmation. label Jul 30, 2024
@github-actions github-actions bot removed the 2 - in development Issues that are actively being worked on. label Jul 30, 2024
@github-actions github-actions bot assigned geospatialem and DitwanP and unassigned benelan Jul 30, 2024
Copy link
Contributor

Installed and assigned for verification.

@benelan
Copy link
Member

benelan commented Jul 30, 2024

Copied from the PR body:

Ensure the initial value is within the min/max range. This is in line with the existing behavior, but it is not ideal.

The plan is to stop automatically changing the value to the min/max when it is out of range, and rely on form constraint validation instead. However, doing so would be a breaking change, so it's on hold until v3.

Verification notes

The behavior after this is installed will look the same as the repro sample. The key is to check the value of the component in the form submission callback:

form.onsubmit = (event) => {
  console.log(event.target.elements["date-picker"].value);
  ...
}

Here is an updated repro sample.

@jcfranco jcfranco added future breaking change Issues and pull requests with deprecation(s), requires a breaking change in a future milestone. and removed breaking change Issues and pull requests with code changes that are not backwards compatible. labels Jul 30, 2024
@DitwanP
Copy link
Contributor

DitwanP commented Jul 30, 2024

@benelan to be clear the repro from the issue body submits the value of the component but the behavior we want for now is to actually submit the min value right? That's what I'm getting in the updated repro just want to double check.

@benelan
Copy link
Member

benelan commented Jul 30, 2024

@benelan to be clear the repro from the issue body submits the value of the component but the behavior we want for now is to actually submit the min value right? That's what I'm getting in the updated repro just want to double check.

Yes, that's correct!

@DitwanP
Copy link
Contributor

DitwanP commented Jul 30, 2024

🍡 Verified locally on dev

@DitwanP DitwanP closed this as completed Jul 30, 2024
@DitwanP DitwanP added 4 - verified Issues that have been released and confirmed resolved. and removed 3 - installed Issues that have been merged to master branch and are ready for final confirmation. labels Jul 30, 2024
calcite-admin pushed a commit that referenced this issue Jul 30, 2024
**Related Issue:** #9282

## Summary

Ensure the initial value is within the min/max range. This is in line
with the existing behavior, but it is not ideal.

The plan is to stop automatically changing the value to the min/max when
it is out of range, and rely on form constraint validation instead.
However, doing so would be a breaking change, so it's on hold until v3.

## Verification notes

The behavior after this is installed will look the same as the [repro
sample](https://codepen.io/benelan/pen/VwOGwZy). The key is to check the
value of the component in the form submission callback:

```js
form.onsubmit = (event) => {
  console.log(event.target.elements["date-picker"].value);
  ...
}
```

Here is an [updated repro
sample](https://codepen.io/benelan/pen/dyBNVMx?editors=1111).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. ArcGIS Field Apps Issues logged by ArcGIS Field Apps team members. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. calcite-components Issues specific to the @esri/calcite-components package. estimate - 3 A day or two of work, likely requires updates to tests. future breaking change Issues and pull requests with deprecation(s), requires a breaking change in a future milestone. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - high Issue should be addressed in the current milestone, impacts component or core functionality
Projects
None yet
Development

No branches or pull requests

5 participants