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

[Combobox] add min-items property and require a minimum number of chips #5226

Closed
avezina opened this issue Aug 26, 2022 · 7 comments
Closed
Assignees
Labels
c-combobox Issues that pertain to the calcite-combobox and related components design Issues that need design consultation prior to development. enhancement Issues tied to a new feature or request. estimate - 5 A few days of work, definitely requires updates to tests. has workaround Issues have a workaround available in the meantime. low risk Issues with low risk for consideration in low risk milestones p - medium Issue is non core or affecting less that 60% of people using the library ready for dev Issues ready for development implementation.

Comments

@avezina
Copy link

avezina commented Aug 26, 2022

Description

Provide the option to set a required minimum number of chips selected.

Acceptance Criteria

  • By default, no min is set.
  • If a min is set:
    • then the user cannot dismiss chips any further once the limit is met
    • the input is invalid until the min number of chips is met
  • The item that was initially selected does not need to be the one that remains: once adding more chips, a user can also dismiss the initial one

Suggestions:

Perhaps we don't need to remove the dismiss (x) button from the min chips, but instead provide the required UI (e.g. red outline and hint) as for a required input, with a message for how many inputs are expected. This would require more error handling, but would be more in line with how this type of requirement is usually implemented?

So basically, a default chip value or values can be set, or none.
If none, or if the minimum is not met, the Combobox needs to display a required UI (red outline input box and hint text for the required number of chips).

Relevant Info

Related enhancement for maxChipsDisplayed: #4326 - but in our user case no max needs to be defined.

Which Component

Calcite-Combobox

Example Use Case

Working with Electric Utility Network data and the JSAPI UtilityNetworkTrace widget.
A user wants to run a Downstream trace to identify assets downstream from an Electrical Switch asset.
The Electrical Switch has 4 positions. The end user may select one of many positions the Trace can start from or end at.
In the Combobox, the default position chip is always selected as a minimum. The user can add more positions (up to 4 in this case), but there must always be at least one position selected.

This is only a simple example. In Telecom, there could be hundreds and thousands of terminals (think a patch panel where hundreds/thousands of terminals where fiber optic strands would connect to) - the Combobox makes it easy to search for a value and dismiss seelcted chips.

@avezina avezina added 0 - new New issues that need assignment. enhancement Issues tied to a new feature or request. needs triage Planning workflow - pending design/dev review. labels Aug 26, 2022
@macandcheese macandcheese added the c-combobox Issues that pertain to the calcite-combobox and related components label Mar 22, 2023
@macandcheese macandcheese added the design Issues that need design consultation prior to development. label Apr 3, 2023
@geospatialem geospatialem added this to the 2023 May Priorities milestone Apr 17, 2023
@geospatialem geospatialem removed the needs triage Planning workflow - pending design/dev review. label Apr 17, 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. labels Apr 17, 2023
@geospatialem geospatialem added the p - low Issue is non core or affecting less that 10% of people using the library label May 2, 2023
@geospatialem
Copy link
Member

Reassigning to June for design considerations prior to development implementation.

@ashetland
Copy link
Contributor

ashetland commented Jun 29, 2023

After many discussions with the team, in order to keep the user in control, we’ve decided the best path forward is to not prevent closing of chips / deselecting of items. If the user deselects too many items the input will be marked invalid, notifying the user that a correction needs to be made. Input Message should be used to explain the error state.

This allows for a simple interaction that does not force the user into a workflow of having to first select extra items just to remove a previous selection. It also prevents possible confusion / frustration about why they’re being prevented from removing a selection.

Prop name

Suggested name for this prop is min-selection. This is to not confuse it with max-items which has an unrelated purpose.

Invalid styling

Invalid styling should match calcite-input. Updated invalid styling may result from #4598.

When does this happen?

Combobox would be marked invalid onblur. This is to prevent an invalid state while the user is making an initial selection.

While closed, Combobox would be marked invalid when the user removes too many item chips. When then opened, it would remain invalid until the user selects the required minimum.

cc @jcfranco

@ashetland ashetland added the ready for dev Issues ready for development implementation. label Jun 29, 2023
@github-actions github-actions bot added 0 - new New issues that need assignment. needs milestone Planning workflow - pending milestone assignment, has priority and/or estimate. and removed design Issues that need design consultation prior to development. 1 - assigned Issues that are assigned to a sprint and a team member. labels Jun 29, 2023
@github-actions github-actions bot removed this from the Design Sprint milestone Jun 29, 2023
@github-actions
Copy link
Contributor

cc @geospatialem, @brittneytewks

@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. labels Jul 1, 2024
@eriklharper eriklharper added has workaround Issues have a workaround available in the meantime. and removed 1 - assigned Issues that are assigned to a sprint and a team member. labels Jan 17, 2025
@eriklharper
Copy link
Contributor

eriklharper commented Jan 17, 2025

Confirmed via chat that this is acceptable with @avezina: workaround is to simply set status="invalid" and validationMessage when the desired minimum selection is not met. Something along these lines:

if (this.minSelection > 0 && this.selectedItems.length < this.minSelection) {
  this.status = "invalid";
  // TODO: use translated messages here
  this.validationMessage = `This field requires at least ${this.minSelection} item${this.minSelection > 1 ? "s" : ""} to be selected.`;
} else {
  this.status = "valid";
  this.validationMessage = "";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-combobox Issues that pertain to the calcite-combobox and related components design Issues that need design consultation prior to development. enhancement Issues tied to a new feature or request. estimate - 5 A few days of work, definitely requires updates to tests. has workaround Issues have a workaround available in the meantime. low risk Issues with low risk for consideration in low risk milestones p - medium Issue is non core or affecting less that 60% of people using the library ready for dev Issues ready for development implementation.
Projects
None yet
Development

No branches or pull requests

7 participants