Calcite-components: provide a way to not show the dismiss X in chips

Created on 18 Apr 2020  路  11Comments  路  Source: Esri/calcite-components

There are places where we want to use the chips in a "read only" view, so we don't want to show the "X" b/c we don't want users to be able to dismiss it.

To me a dismissible property would make sense, but for the current behavior that would have to default to true, which means you couldn't just use the presence of the attribute to indicate true. Defaulting to false would be a breaking change. I'm having a hard time coming up w/ an opposite term other than readOnly.

If maintainers agree w/ the idea and could weigh in on the API I'd be glad to take a crack at a PR.

enhancement

All 11 comments

I should mention, that personally I think the default should be false, but maybe it's more common in other apps that these are used in editing contexts.

Agreed on both counts - good enhancement that we should add, and, "has a dismiss button" is probably the primary use case so having to set dismissible for that seems weird.

Open to naming options for "readOnly", I'm sure some folks might have ideas, but to your point I'm having trouble thinking of anything else either 馃槅

If there's no other feedback from @Esri/calcite-components on nomenclature, we can certainly roll with readOnly for the time being to get this feature added in...

IMO It would be better to have the default be a chip with no x. By adding a prop you are "adding" ui, so it makes more sense to me. In calcite-notice we add an X if the user adds the prop dismissible. I think this would be a very nice parallel as the same prop has the same behavior in both components.

This would be a breaking change, but I think it makes sense. That's my 2垄

Makes sense to me. We also use "active" in most components that have a hidden or dismissed state to make it visible - same here for consistency could make sense?

will the chip with no x be dismissible by clicking it? when would you use a chip that isn't dismissible? as a tag?

It would be read only... I think non-dismissible chips have a lot of uses - input values that turn into chips that are deleted with a keyboard event, attribute labels on cards, lots of good use cases here: https://material.io/components/chips#input-chips

It might actually be worth documenting some examples of "choice chips" as shown there (possible currently with our icon prop, but we don't have a good "selected" state - maybe another enhancement altogether)...

k that makes sense.

I was going to suggest noDismiss instead of readOnly, but when I saw @paulcpederson's comment, I really think dismissible is the best API, esp for consistency w/ calcite-notice.

I'd like to submit a PR w/ dismissable as a breaking change if there's agreement around that. I'm hoping that's something you could merge and release given that this library is in beta, right?

@tomwayson - yep, of course. That'd be awesome - much appreciated.

Sweet, thanks @tomwayson! breaking changes are fine in beta, just make sure to add it to the CHANGELOG.

Was this page helpful?
0 / 5 - 0 ratings