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

[EuiTreeView] [EuiTreeViewNode] changed label PropType in tree_view to ReactNode #4352

Merged
merged 2 commits into from
Dec 15, 2020

Conversation

Dishebh
Copy link
Contributor

@Dishebh Dishebh commented Dec 4, 2020

Summary

Fixes #4323
Changed label PropType in tree_view to ReactNode

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@cla-checker-service
Copy link

cla-checker-service bot commented Dec 4, 2020

💚 CLA has been signed

@Dishebh Dishebh changed the title changed label PropType in tree_view to ReactNode [EuiTreeView] [EuiTreeViewNode] changed label PropType in tree_view to ReactNode Dec 4, 2020
Copy link
Contributor

@snide snide left a comment

Choose a reason for hiding this comment

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

Thanks @Dishebh. Outside of signing the contributor agreement, you'll need to add a changelog to this fix. Here's a suggested one. Will merge on changes.

- Changed `label` type from `string` to `ReactNode` in `EuiTreeViewNode` ([#4352](https://github.com/elastic/eui/pull/4352))

@snide
Copy link
Contributor

snide commented Dec 4, 2020

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4352/

@Dishebh Dishebh requested review from snide and myasonik December 7, 2020 08:57
src/components/tree_view/tree_view.test.tsx Outdated Show resolved Hide resolved
src/components/tree_view/tree_view.tsx Outdated Show resolved Hide resolved
) : null}
<span
ref={ref}
title={innerText}
Copy link
Contributor

Choose a reason for hiding this comment

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

@myasonik I believe the title here is not needed, as it is the snapshot of the text content in this element anyway?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need it for any a11y reasons

@myasonik
Copy link
Contributor

jenkins test this

1 similar comment
@Dishebh
Copy link
Contributor Author

Dishebh commented Dec 10, 2020

jenkins test this

@cchaos
Copy link
Contributor

cchaos commented Dec 10, 2020

Sorry, only team members can kick off a jenkins build. I'll get one started for you.

Jenkins, test this

@chandlerprall
Copy link
Contributor

The yarn.lock changes look like they are tripping up Typescript (it appears multiple @types/react are present). Reverting those changes so it matches the version on master should resolve.

@Dishebh
Copy link
Contributor Author

Dishebh commented Dec 12, 2020

The EuiTreeView component's first unit test EuiTreeView › is rendered somehow fails, stating -

Warning: Failed prop type: Invalid prop `aria-label` of type `object` supplied to `EuiTreeView`, expected `string`.
        in EuiTreeView
        in Context.Consumer
        in EuiI18n
        in EuiInnerText
        in ul
        in div
        in EuiText
        in Context.Provider
        in EuiTreeView

@chandlerprall
Copy link
Contributor

@Dishebh I've pushed some changes directly to your branch to resolve that test.

nodeLabel: innerText, was undefined during the first render, which caused the resulting ariaLabel value to be an array of strings instead of a single string. This caused the value to be an object instead of string, triggering the proptype warning.

I added a fallback value fallback={typeof node.label === 'string' ? node.label : ''} so:

  1. the test, which uses a string, would not need any snapshot changes
  2. ensure innerText is never undefined, instead falling back to an empty string

I also modified a utility method in EuiI18n so future occurrences of undefined sneaking in would be treated appropriately. This change by itself would have resolved the test error, but wouldn't have maintained the same test snapshot.

@chandlerprall
Copy link
Contributor

jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4352/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

Changes LGTM, pulled & tested locally by passing a JSX element as the label.

@chandlerprall chandlerprall merged commit ecd065b into elastic:master Dec 15, 2020
@Dishebh Dishebh deleted the label branch December 16, 2020 05:05
@Dishebh
Copy link
Contributor Author

Dishebh commented Dec 16, 2020

Thanks a lot, @chandlerprall, will surely look at the changes you made.

@prcdpr
Copy link

prcdpr commented Dec 16, 2020

Thank you guys for this change 👏

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

Successfully merging this pull request may close these issues.

[EuiTreeView] [EuiTreeViewNode] Allow for label types other than string
7 participants