-
Notifications
You must be signed in to change notification settings - Fork 841
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
useInnerText
; Fix EuiListGroupItem
title attrs
#2100
useInnerText
; Fix EuiListGroupItem
title attrs
#2100
Conversation
expect(component).toMatchSnapshot(); | ||
}); | ||
|
||
// test('uses innerText', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working on getting these types of tests to run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still stumped. I'm not actually sure if Enzyme can handle it.
Can you add this to the EuiFilterButton component as well? |
Ok, ready for review (sorry; should've made it Draft to start) I'll figure out how to correctly test hooks in the meantime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you alter the docs for innerText
a bit?
- I'm thinking the big Usage section isn't really needed because the snippets should take care of that. (You can also reference the snippet tab in the explanation).
- I'd add a bit about why a consumer would need this or really our typically usage for it (truncation).
- Update the examples so it's a little clearer what you are trying to show.
Something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more docs comments
|
||
<EuiSpacer /> | ||
|
||
<EuiListGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these other two can be combined into one group even though it will still show a tooltip on the wrapped lines one.
- First item
- Second item
- Third very, very long item that will surely force truncation
- Fourth very, very long item with wrapping enabled that will not force truncation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TY! Just one more thing, I promise...
Can you add two snippets for this example?
<EuiListGroup showToolTips>...</EuiListGroup>
<EuiListGroupItem
wrapText
label={label}
/>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thompsongl Did you see my last comment on here? ^^
Love the simplicity! This doesn't account for data that updates. Let's throw a mutation observer on that ref as well to catch text changes. Unfortunately we can't use |
This also doesn't update if the ref changes (important for re-attaching a mutation observer as well). This is a stupid bit of code, but this modified doc example demonstrates:
with
console output is
the |
@chandlerprall I stopped using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM; tested examples locally; this is so cool ❄️
Summary
Adds a custom hook (
useInnerText
), a render prop component (EuiInnerText
, for class components), and uses the former to fix #2011.EuiListGroupItem
would provisionally get atitle
attribute if it was suspected that its content would truncate. This was unnecessary if it used custom tooltips or was allowed to wrap lines. Logic added fixes this.EuiListGroupItem
also accepts Reactnode
children, which would make the rendered value of thetitle
attribute unreadable ([object Object]
).useInnerText
now updates the attribute value to match the text content of the list item.Checklist
- [ ] This was checked in mobile- [ ] This was checked in IE11- [ ] This was checked in dark mode- [ ] Any props added have proper autodocs- [ ] This was checked against keyboard-only and screenreader scenarios- [ ] This required updates to Framer X components