Skip to content

calcite-select: Allow having no initial value #4032

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

Closed
1 task
jgibson02 opened this issue Feb 1, 2022 · 13 comments
Closed
1 task

calcite-select: Allow having no initial value #4032

jgibson02 opened this issue Feb 1, 2022 · 13 comments
Assignees
Labels
4 - verified Issues that have been tested, confirmed as mitigated, and are ready to close. 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. has workaround Issues have a workaround available in the meantime. p - high Issue should be addressed in the current milestone, impacts component or core functionality Professional Services - Services Delivery Issues logged by Professional Services - Services Delivery team members

Comments

@jgibson02
Copy link
Contributor

jgibson02 commented Feb 1, 2022

Description

It is sometimes useful to have no initial value for a select to coerce the user to make an explicit decision. Currently this seems to not be supported by calcite-select since it seems to always be initialized with the first calcite-option child's value if value is undefined and no calcite-option is selected. In plain HTML, <option hidden disabled /> might be used, however doing <calcite-option hidden disabled /> still causes it to be visible in the menu.

Acceptance Criteria

  • When no value is set, and no calcite-option is selected, the calcite-select renders its placeholder and does not initialize itself with a default value

Relevant Info

No response

Which Component

calcite-select

Example

https://codepen.io/arjan_esrinl/pen/ZEmgaVv

@jgibson02 jgibson02 added enhancement Issues tied to a new feature or request. 0 - new New issues that need assignment. needs triage Planning workflow - pending design/dev review. labels Feb 1, 2022
@macandcheese
Copy link
Contributor

This one's tough as we match native behavior and there is no native placeholder attribute.

The single-select combobox could accomplish this:

<calcite-combobox placeholder="Select a value" selection-mode="single">
    <calcite-combobox-item value="Engineering" text-label="Engineering"></calcite-combobox-item>
    <calcite-combobox-item value="Architecture" text-label="Architecture"></calcite-combobox-item>
    <calcite-combobox-item value="Construction" text-label="Construction"></calcite-combobox-item>
</calcite-combobox>

Although the above does not allow you to clear selection - not sure if that is desirable for your workflow.

@jgibson02
Copy link
Contributor Author

@macandcheese what're your thoughts on supporting hidden on a calcite-option to hide it from the list and act like a placeholder akin to the native behavior?

@macandcheese
Copy link
Contributor

That would work - it seems like that works only when hidden is the first option. Maybe we could just render that internally based on the presence of an (added) placeholder attribute? Would be open to either option there.

@jgibson02
Copy link
Contributor Author

If it only works for the first option, then your suggestion certainly sounds cleaner to me rather than adding a hidden prop and depending on documenting that behavior.

@macandcheese
Copy link
Contributor

@jcfranco @benelan thoughts on re-triaging this or considering having a placeholder affordance for a select? It could be a bit of a break from native behavior but it seems like we keep getting requests for it as well.

@ReneU
Copy link

ReneU commented Jun 30, 2022

+1 We need this to allow having no initial value for some components in ArcGIS Velocity. We have some required fields that don't allow for good defaults such as this one:
image

@ReneU
Copy link

ReneU commented Aug 9, 2022

@macandcheese @jcfranco @benelan are there any plans to support this in one of the upcoming releases? We have a lot of UIs in ArcGIS Velocity we would like to migrate but this is the only issue blocking us from doing so since we don't want to have a mixed experience (UI controls from different component libraries on the same page).

@jcfranco
Copy link
Member

jcfranco commented Aug 9, 2022

Would using an 'empty' option work in the meantime? https://codepen.io/jcfranco/pen/oNqMBRJ?editors=1010

it seems to always be initialized with the first calcite-option child's value if value is undefined

Assuming ☝️ was fixed, would this address this issue or are there additional functional differences from the MDN example?

@ReneU
Copy link

ReneU commented Aug 10, 2022

@jcfranco yes, I think we could go with the 'empty' option for now. Thank you.

It seems like it's still getting initialized with the first calcite-option child's value if value is undefined. However, it looks like this matches the native behavior. I guess that's not a blocker for us and we could implement a workaround.

The only remaining thing that would be great to have (and is a functional difference) is the hidden prop, as discussed above.

@jcfranco jcfranco added the has workaround Issues have a workaround available in the meantime. label Aug 3, 2023
@geospatialem geospatialem added bug Bug reports for broken functionality. Issues should include a reproduction of the bug. and removed enhancement Issues tied to a new feature or request. labels Sep 5, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

It looks like this issue is missing some information:

  • A codepen, codesandbox, or jsbin that reproduces the issue. Alternatively, a documentation sample can be used if the issue is reproducible. If you are experiencing build or Node related errors, please provide a GitHub repo for the sample.

Issues without reproduction samples may not be prioritized. If you were unable to create a sample, please try to answer any questions that arise once development begins. Thanks for your understanding.

@github-actions github-actions bot added the incomplete issue report New issues missing important information, and unless provided, they will be closed after 5 days. label Sep 5, 2023
@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. incomplete issue report New issues missing important information, and unless provided, they will be closed after 5 days. labels Sep 5, 2023
@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 Sep 5, 2023
@geospatialem geospatialem added Professional Services - Services Delivery Issues logged by Professional Services - Services Delivery team members calcite-components Issues specific to the @esri/calcite-components package. labels Sep 5, 2023
@geospatialem
Copy link
Member

@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 Sep 7, 2023
jcfranco added a commit that referenced this issue Sep 19, 2023
**Related Issue:** #4032

## Summary

This fixes an issue where an empty string value was treated as value not
set and would therefore fall back to the label as the value.
@jcfranco jcfranco added 3 - installed Issues that have been merged to the "dev" branch and/or are ready for QA/QC. and removed 2 - in development Issues that are actively being worked on. labels Sep 19, 2023
@github-actions github-actions bot assigned geospatialem and unassigned jcfranco Sep 19, 2023
@github-actions
Copy link
Contributor

Installed and assigned for verification.

@geospatialem geospatialem added 4 - verified Issues that have been tested, confirmed as mitigated, and are ready to close. and removed 3 - installed Issues that have been merged to the "dev" branch and/or are ready for QA/QC. labels Sep 20, 2023
@geospatialem
Copy link
Member

Verified in 1.9.0-next.5.

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 tested, confirmed as mitigated, and are ready to close. 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. has workaround Issues have a workaround available in the meantime. p - high Issue should be addressed in the current milestone, impacts component or core functionality Professional Services - Services Delivery Issues logged by Professional Services - Services Delivery team members
Projects
None yet
Development

No branches or pull requests

6 participants