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

Setting combobox value prop emits calciteComboboxChange event #8970

Closed
2 of 6 tasks
nwhittaker opened this issue Mar 19, 2024 · 3 comments
Closed
2 of 6 tasks

Setting combobox value prop emits calciteComboboxChange event #8970

nwhittaker opened this issue Mar 19, 2024 · 3 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. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - medium Issue is non core or affecting less that 60% of people using the library p2 - want for current milestone User set priority status of p2 - want for current milestone

Comments

@nwhittaker
Copy link
Contributor

nwhittaker commented Mar 19, 2024

Check existing issues

Actual Behavior

Setting the value prop on a <calcite-combobox> component programmatically results in calciteComboboxItemChange and calciteComboboxChange events being emitted.

Expected Behavior

Setting the value prop on a <calcite-combobox> component programmatically does not result in calciteComboboxItemChange and calciteComboboxChange events being emitted.

Reproduction Sample

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

Reproduction Steps

  1. Visit the code sample and open the console.
  2. Click the Select random and see event handler messages appear.

Alternative

  1. Inspect any <calcite-combobox-item> element in devtools.
  2. Manually toggle the element's selected attribute and see event handler message appears.

Reproduction Version

3.6.0

Relevant Info

No response

Regression?

No response

Priority impact

p2 - want for current milestone

Impact

Typically programmatic changes to an element do not result in events being fired. They're usually only fired in response to some sort of UI interaction from the user.

One difficulty with firing these events programmatically is they're firing during the component's update lifecycle. Specifically, in Stencil, we want to reuse the same combobox element with a different set of options and selected value. During the update, the calciteComboboxChange event is firing (sometimes while the combobox still has an empty value). As a result, our listeners are ending up with an incorrect value and think the component has been dirtied by a user input.

I have a codepen that better simulates the update lifecycle issue:

  1. Click the Recycle combobox button to simulate a full update to the component's value and items.
  2. During the update, notice the calciteComboboxChange is fired and the Selected value output is updated with the combobox's value at that point in time which is empty.
  3. After the update, click the Output value button to update the output with the combobox's current value which has been quietly set to "A".

A workaround for this particular scenario is to set selected on the new combobox items and let the combobox component derive the value. However this is not a maintainable approach and doesn't solve the problem of listeners thinking the combobox has been dirtied.

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 Mar 19, 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 Mar 19, 2024
@nwhittaker nwhittaker added p3 - want for upcoming milestone and removed impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone labels Mar 21, 2024
@geospatialem geospatialem added p - medium Issue is non core or affecting less that 60% of people using the library estimate - 3 A day or two of work, likely requires updates to tests. needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. and removed needs triage Planning workflow - pending design/dev review. labels Apr 15, 2024
@geospatialem geospatialem added impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone and removed p3 - want for upcoming milestone labels May 21, 2024
@geospatialem geospatialem added this to the 2025-01-28 - Jan Release milestone Aug 7, 2024
@geospatialem geospatialem removed the needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. label Aug 7, 2024
@github-actions github-actions bot added the p2 - want for current milestone User set priority status of p2 - want for current milestone label Nov 5, 2024
@anveshmekala anveshmekala self-assigned this Jan 13, 2025
@anveshmekala
Copy link
Contributor

Hi @nwhittaker , issue is resolved in latest version of calcite.

Codepen https://codepen.io/anvesh-mekala/pen/dPbepaJ

@anveshmekala anveshmekala added 2 - in development Issues that are actively being worked on. and removed 0 - new New issues that need assignment. labels Jan 13, 2025
anveshmekala added a commit that referenced this issue Jan 22, 2025
…#11281)

**Related Issue:** #8970 

## Summary

Adds the following E2E tests for combobox:

- should not emit calciteComboboxChange event when value attribute is
updated
- should not emit calciteComboboxItemChange event when selected
attribute is toggled
@anveshmekala anveshmekala added 3 - installed Issues that have been merged to master branch and are ready for final confirmation. and removed 2 - in development Issues that are actively being worked on. labels Jan 22, 2025
@github-actions github-actions bot assigned geospatialem and DitwanP and unassigned anveshmekala Jan 22, 2025
Copy link
Contributor

Installed and assigned for verification.

@geospatialem geospatialem removed the 3 - installed Issues that have been merged to master branch and are ready for final confirmation. label Jan 23, 2025
@geospatialem geospatialem added the 4 - verified Issues that have been released and confirmed resolved. label Jan 23, 2025
@geospatialem
Copy link
Member

Hi @nwhittaker , issue is resolved in latest version of calcite.

Codepen https://codepen.io/anvesh-mekala/pen/dPbepaJ

Verified with Anvesh's Codepen and Nate's updated Codepen in 3.0.0-next.108: https://codepen.io/geospatialem/pen/raBqbEQ

benelan pushed a commit that referenced this issue Feb 8, 2025
…#11281)

**Related Issue:** #8970 

## Summary

Adds the following E2E tests for combobox:

- should not emit calciteComboboxChange event when value attribute is
updated
- should not emit calciteComboboxItemChange event when selected
attribute is toggled
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. impact - p2 - want for an upcoming milestone User set priority impact status of p2 - want for an upcoming milestone p - medium Issue is non core or affecting less that 60% of people using the library p2 - want for current milestone User set priority status of p2 - want for current milestone
Projects
None yet
Development

No branches or pull requests

4 participants