carbon-design-system / ibm-products

A Carbon-powered React component library for IBM Products
https://ibm-products.carbondesignsystem.com
Apache License 2.0
97 stars 138 forks source link

Condition builder initial release review #6032

Closed elycheea closed 1 month ago

elycheea commented 2 months ago

Review for release

Readiness

Engineering review

Standards

Testing

Documentation

[^1]: Any labels, text, or other strings within a component should use a prop. [^2]: See Carbon’s Developer Handbook for guidance on class names.

makafsal commented 1 month ago

@amal-k-joy

Accessibility violations

image

image

image

https://github.com/user-attachments/assets/2eafdc04-0ea9-4414-930c-25a1e5252424

https://github.com/user-attachments/assets/aa76f403-10df-40df-84a9-d10f2627dfcc

image

https://github.com/user-attachments/assets/10f13524-9d4c-416a-937b-cb2dbca60517

davidmenendez commented 1 month ago

there's a lot to go through here, so i'm going to take my time, but i'd like to point out one issue now that's very glaring to me. in light of our recent discussions to give the user more control i think one of the best places to start is here with ConditionBuilder.

in ConditionBuilderContent.tsx we have this effect running to declare the builder is active

  useEffect(() => {
    if (rootState?.groups?.length) {
      setIsConditionBuilderActive(true);
    } else {
      setIsConditionBuilderActive(false);
    }

    if (getConditionState) {
      getConditionState(rootState ?? {});
    }

    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [rootState]);

this is a good example of internal state we should avoid and let the user handle. i would simply remove this code and add a prop for the user to control the open or active state of the component.

the more effects we can remove the more unintentional side effects we can mitigate.

davidmenendez commented 1 month ago

posting this comment from Linda for documentation purposes while we are going through the release review process as of 9/19/24

Recap on Condition Builder from today’s standup: Okay to merge PR for the usage docs to go live on new website Hold on bringing to stable Document only any a11y issues from either AvT or screenreader/voiceover. Issues created for bugs should be documented but don’t have to pick up work on those bugs.

davidmenendez commented 1 month ago

the other major thing that i wanted to point out is that the translations need to be handled at the prop level and not be imported directly from the component folder import { useTranslations } from '../utils/useTranslations';

if we want to expose some kind of hook at the consumer level that's fine, but honestly it's probably just easier to provide the json structure in the docs and let the user pass the data structure directly. translations={clientTranslationObj}

amal-k-joy commented 1 month ago

there's a lot to go through here, so i'm going to take my time, but i'd like to point out one issue now that's very glaring to me. in light of our recent discussions to give the user more control i think one of the best places to start is here with ConditionBuilder.

in ConditionBuilderContent.tsx we have this effect running to declare the builder is active

  useEffect(() => {
    if (rootState?.groups?.length) {
      setIsConditionBuilderActive(true);
    } else {
      setIsConditionBuilderActive(false);
    }

    if (getConditionState) {
      getConditionState(rootState ?? {});
    }

    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [rootState]);

this is a good example of internal state we should avoid and let the user handle. i would simply remove this code and add a prop for the user to control the open or active state of the component.

the more effects we can remove the more unintentional side effects we can mitigate.

Hey @davidmenendez , Thanks for looking into this. This useEffect is required when the user deletes all the conditions , then we need to show back the Add condition button. So we need to listen to the root state for this. Also we have kept the Add conditionbutton as part our component. Image

matthewgallo commented 1 month ago

Closing initial review, we'll open follow up issues for items discussed here.

amal-k-joy commented 1 month ago

the other major thing that i wanted to point out is that the translations need to be handled at the prop level and not be imported directly from the component folder import { useTranslations } from '../utils/useTranslations';

if we want to expose some kind of hook at the consumer level that's fine, but honestly it's probably just easier to provide the json structure in the docs and let the user pass the data structure directly. translations={clientTranslationObj}

Hey, Based on our earlier discussion on the implementation of translation, we had decided to implement by exposing a prop translateWithId, which is a callback to the user that will return the translated text. This approach aligns with core carbon as well. Here useTranslations is just a local hook that will grab the required text to our components either from users callback or from default translation object. May be we can mention the expected translations keys in the story book docs