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

revert: table empty state icon changes #3850

Merged
merged 1 commit into from
Mar 19, 2024
Merged

Conversation

herleraja
Copy link
Collaborator

Summary

  • In the commit ad2c042 we are not setting the empty value by default causing the downstream application to fail

Change List (commits, features, bugs, etc)

  • revert: table empty state icon changes

Acceptance Test (how to verify the PR)

  • tests here

Regression Test (how to make sure this PR doesn't break old functionality)

  • tests here

Things to look for during review

  • Make sure all references to iot or bx class prefix is using the prefix variable
  • (React) All major areas have a data-testid attribute. New test ids should have test written to ensure they are not changed or removed.
  • UI should be checked in RTL mode to ensure the proper handling of layout and text.
  • All strings should be translatable.
  • The code should pass a11y scans (The storybook a11y knob should show no violations). New components should have a11y test written.
  • Unit test should be written and should have a coverage of 90% or higher in all areas.
  • All components should be passing visual regression test. For new styles or components either a visual regression test should be written for all permutations or the base image updated.
  • Changes or new components should either write new or update existing documentation.
  • PR should link and close out an existing issue

In the commit ad2c042 we are not setting the empty value by default causing the downstream application to fail
Copy link

netlify bot commented Mar 19, 2024

Deploy Preview for carbon-addons-iot-react ready!

Name Link
🔨 Latest commit 4a03fa2
🔍 Latest deploy log https://app.netlify.com/sites/carbon-addons-iot-react/deploys/65f9533cfdd3920008f1acf4
😎 Deploy Preview https://deploy-preview-3850--carbon-addons-iot-react.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -86,7 +86,7 @@ const EmptyTable = ({
/>
) : (
<EmptyState
icon={emptyStateIcon ?? 'empty'}
icon={emptyStateIcon !== '' ? emptyStateIcon : 'empty'}
Copy link
Contributor

Choose a reason for hiding this comment

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

I see this is reverting, but what was the original code before you did any of this enumeration stuff.

The default value for emptyStateIcon is '', so in the previous change if emptyStateIcon is undefined, then it would bet set to '' and therefor no icon. In the new change if emptyStateIcon is undefined it will be set to '' and based on the condition it will use 'empty'. Is that the correct behaviour?

was the original behaviour such that if the prop was no specified then it would use the 'empy' icon? if so, then I think we are good.

Copy link
Collaborator

@cgirani cgirani Mar 19, 2024

Choose a reason for hiding this comment

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

The empty fallback would work only if emptyStateIcon is undefined or null in the defaultProps since this is an empty string, that is a "valid value" for the Nullish coalescing operator... that's why "empty" is not being used.

So if we want it to work with ?? the default props need to be undefined/null otherwise makes sense to revert to this code

Copy link
Contributor

Choose a reason for hiding this comment

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

@cgirani The challenge (and what I'm trying to get to, is the default behaviour before the changes were in place).

This "revert" comes as a request from a downstream consumer where this change caused changes in the default behaviour of the component. (I suspect that previously they were not setting the emptyStateIcon and was seeing empty, and after the bullish coalescing operator was used they got no icon (because the default value is an empty string it can never be undefined).

as a rule of thumb when we update components adding new features, etc, we never want to change the default behaviour of the component and I think this change did that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@stuckless yup. you are correct. Default behavior was having an empty icon. I could have updated the monitor code but the issue is we can't update our old codebase easily (8.11.x and 8.10.x). So just to keep the exact same behaviour I have set this to default.

@cgirani One more thing to note is changing the prop name also can break the downstream system. example in the Previous commit noDataIcon changed to emptyStateIcon.
we should avoid this kind of change in patch releases so that we dont break downstream systems.

Since the monitor does not use noDataIcon and depends on default behavior we are not facing any issues.

@kodiakhq kodiakhq bot merged commit 86eb636 into next Mar 19, 2024
29 checks passed
@kodiakhq kodiakhq bot deleted the fix-emptystate-runtime-error branch March 19, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants