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

fix: [sc-27302] Multiselect filter correctly disables chips in modal; #782

Merged

Conversation

apattersonATX-HB
Copy link
Contributor

Multiselect filter will now correctly disable options when rendered as a ToggleChipGroup.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #27302: [FE] Comp Filter Options based on comps returned.

...Css.white.bgLightBlue700.$,
":hover:not(:isDisabled)": Css.bgLightBlue800.$,
}
: { ":hover:not(:isDisabled)": Css.bgGray300.$ }),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: is :isDisabled correct? I've seen :disabled:

https://developer.mozilla.org/en-US/docs/Web/CSS/:disabled

But not :isDisabled. Does this somehow magically work with the data-disabled attribute?

I was expecting per:

https://stackoverflow.com/a/17249001

Something like :not([data-disabled="true"])

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I inserted :isDisabled because react-aria's useCheckboxGroupItem props extends InputBase type down the chain which does have the isDisabled prop. It'll actually work without using data-disabled attribute so maybe it's just a quirk of react-aria?

But yea probably better to do it the traditional CSS way.

import { Label } from "src/components/Label";
import { Css } from "src/Css";
import { useTestIds } from "src/utils/useTestIds";

type ToggleChipItemProps = {
label: string;
value: string;
isDisabled?: boolean;
disabledReason?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Instead of two separate props, we typically model this as a union, like:

export interface BeamButtonProps {
  /**
   * Whether the interactive element is disabled.
   *
   * If a ReactNode, it's treated as a "disabled reason" that's shown in a tooltip.
   */
  disabled?: boolean | ReactNode;

That way the user can't do something like isDisabled=false disabledReason="some error" and it's ambiguous that maybe we really be disabled, like does a set disabledReason override the isDisabled is false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats true. Had tunnel vision on the filter so hadn't considered ToggleChipGroup ever using anything besides a string

@apattersonATX-HB apattersonATX-HB force-pushed the sc-27302/fix-modal-multifilter-disable-options branch from 0bfd31f to 4b099a4 Compare January 9, 2023 15:54
Copy link
Contributor

@stephenh stephenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, looks good!

@apattersonATX-HB apattersonATX-HB merged commit 1acfc0c into main Jan 9, 2023
@apattersonATX-HB apattersonATX-HB deleted the sc-27302/fix-modal-multifilter-disable-options branch January 9, 2023 22:40
homebound-team-bot pushed a commit that referenced this pull request Jan 9, 2023
### [2.235.4](v2.235.3...v2.235.4) (2023-01-09)

### Bug Fixes

* [sc-27302] Multiselect filter correctly disables chips in modal; ([#782](#782)) ([1acfc0c](1acfc0c))
@homebound-team-bot
Copy link

🎉 This PR is included in version 2.235.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants