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-time-zone can lose selection on change #11128

Open
2 of 6 tasks
nwhittaker opened this issue Dec 21, 2024 · 1 comment
Open
2 of 6 tasks

input-time-zone can lose selection on change #11128

nwhittaker opened this issue Dec 21, 2024 · 1 comment
Assignees
Labels
2 - in development Issues that are actively being worked on. 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 - 2 Small fix or update, may require updates to tests. impact - p1 - need for current milestone User set priority impact status of p1 - need for current milestone p - high Issue should be addressed in the current milestone, impacts component or core functionality regression Issues that are caused by changes in a release, but were working before that.

Comments

@nwhittaker
Copy link
Contributor

Check existing issues

Actual Behavior

Given a time-zone input this is updated programmatically: If the input's messages, mode, and/or referenceDate props are set at the same time the value prop is, the matching combobox-item (if there is one) is not selected or loses its selection.

Expected Behavior

The matching combobox-item, if any, is selected or remains selected.

Reproduction Sample

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

Reproduction Steps

  1. Visit the repro. sample
  2. If needed, change the offset passed to the setTimeZone() function to be different from your own.
  3. Click the Set time zone button and observe the <calcite-input-time-zone> input's value is cleared instead of matching the offset established in step 2. If it appears to work, try clicking the button a few times and/or clicking the input itself to force a repaint.
  4. Optionally comment out the line of code that sets the input's referenceDate to see the expected behavior.

Reproduction Version

2.13.2

Relevant Info

I believe the issue stems from a race condition in the component's handleTimeZoneItemPropsChange method:

this.updateTimeZoneItems();
this.updateTimeZoneSelection();

The time-zone selection is not waiting for the new list of time-zones. As a result it's finding itself in the old list of time zones which means it never matches a time-zone item in the renderItems() method.

I suspect making the handleTimeZoneItemPropsChange method asynchronous and awaiting the call to updateTimeZoneItems() would be enough to clear up the issue:

-  handleTimeZoneItemPropsChange(): void {
+  async handleTimeZoneItemPropsChange(): Promise<void> {
    if (!this.timeZoneItems) {
      return;
    }

-    this.updateTimeZoneItems();
+    await this.updateTimeZoneItems();
    this.updateTimeZoneSelection();
  }

Regression?

2.12.2

Priority impact

impact - p1 - need for current milestone

Impact

I'm readily encountering this error in a component that constructs <calcite-input-time-zone> inputs in JSX following a data-down/action-up architecture. As a result, the component's rendering engine is setting/updating props on the inputs frequently and in batches. In this less contrived scenario, the inputs' are unusable as their values are almost always cleared after the user makes a selection.

A workaround may be to set the messages, mode, and/or referenceDate props separately from the value prop. However, this adds a degree of complexity that's difficult to generalize.

Calcite package

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

Esri team

ArcGIS Field Apps

@nwhittaker nwhittaker added 0 - new New issues that need assignment. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. needs triage Planning workflow - pending design/dev review. labels Dec 21, 2024
@github-actions github-actions bot added ArcGIS Field Apps Issues logged by ArcGIS Field Apps team members. calcite-components Issues specific to the @esri/calcite-components package. impact - p1 - need for current milestone User set priority impact status of p1 - need for current milestone labels Dec 21, 2024
@geospatialem
Copy link
Member

The above is still present in 3.0.0-next.81 with the same sample set to the next version, the regression occurred between 2.12 and 2.13.

To reproduce:

  1. Open the sample
  2. Select the "Set time zone" button
  3. Select the input-time-zone component
  4. Press esc or the down arrow keys
  5. Observe the input-time-zone value is cleared

@geospatialem geospatialem added the regression Issues that are caused by changes in a release, but were working before that. label Dec 27, 2024
@jcfranco jcfranco self-assigned this Dec 27, 2024
@jcfranco jcfranco added 1 - assigned Issues that are assigned to a sprint and a team member. estimate - 2 Small fix or update, may require updates to tests. p - high Issue should be addressed in the current milestone, impacts component or core functionality and removed 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels Dec 27, 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 Dec 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 - in development Issues that are actively being worked on. 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 - 2 Small fix or update, may require updates to tests. impact - p1 - need for current milestone User set priority impact status of p1 - need for current milestone p - high Issue should be addressed in the current milestone, impacts component or core functionality regression Issues that are caused by changes in a release, but were working before that.
Projects
None yet
Development

No branches or pull requests

3 participants