useInnerText; Fix EuiListGroupItem title attrs#2100
useInnerText; Fix EuiListGroupItem title attrs#2100thompsongl merged 18 commits intoelastic:masterfrom
useInnerText; Fix EuiListGroupItem title attrs#2100Conversation
| expect(component).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| // test('uses innerText', () => { |
There was a problem hiding this comment.
Working on getting these types of tests to run
There was a problem hiding this comment.
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. |
cchaos
left a comment
There was a problem hiding this comment.
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:
|
|
||
| <EuiSpacer /> | ||
|
|
||
| <EuiListGroup> |
There was a problem hiding this comment.
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.
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.
@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 |
chandlerprall
left a comment
There was a problem hiding this comment.
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.EuiListGroupItemwould provisionally get atitleattribute 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.EuiListGroupItemalso accepts Reactnodechildren, which would make the rendered value of thetitleattribute unreadable ([object Object]).useInnerTextnow 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