Added conditional rendering to description in EuiCard#4582
Added conditional rendering to description in EuiCard#4582cchaos merged 13 commits intoelastic:masterfrom
Conversation
|
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? |
src/components/card/card.tsx
Outdated
| </EuiText> | ||
| {description && ( | ||
| <EuiText | ||
| id={`${ariaId}Description`} |
There was a problem hiding this comment.
Wherever in the file we reference this ID, now has to be conditional as well.
(An aria-describedby={id} that doesn't find that id will cause automated accessibility tests to often fail.)
|
@myasonik I have made changes. but I'm a bit skeptical about my approach. Could you please review my changes |
myasonik
left a comment
There was a problem hiding this comment.
@hetanthakkar1 Your approach did technically work at not rendering invalid aria-describedby attributes but it's a little heavy handed in what else it doesn't render 😄
If we move the conditional a little closer to the problem area, we can still render everything else we need to.
src/components/card/card.tsx
Outdated
| if (selectable && description) { | ||
| optionalSelectButton = ( | ||
| <EuiCardSelect | ||
| aria-describedby={`${ariaId}Title ${ariaId}Description`} |
There was a problem hiding this comment.
If earlier in the file you define a variable something like:
const ariaDesc = description ? `${ariaId}Description` : '';
Then you can use it in place of everywhere it's used now
| aria-describedby={`${ariaId}Title ${ariaId}Description`} | |
| aria-describedby={`${ariaId}Title ${ariaDesc}`} |
There was a problem hiding this comment.
I thought of doing the same const ariaDesc = description ? ${ariaId}Description : ''; .But I wasn't sure what should value ariaDesc take i.e. whether ariaDesc = ' ' would work!
src/components/card/card.tsx
Outdated
|
|
||
| let optionalSelectButton; | ||
| if (selectable) { | ||
| if (selectable && description) { |
There was a problem hiding this comment.
We still want to render this content if the description is empty so we can't just not render the whole thing
|
@myasonik I have incorporated the changes. Could you please review |
|
Jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4582/ |
|
@myasonik I am just curious to know why eui-ci build fails so frequently! Most probably it's not related to my PR but is there a way we can fix it |
|
@myasonik Is there anything else i need to change in the code!? |
We've been having a lot of timeouts recently due to the increase in build time. If you update from master you should get a most recent PR that should help reduce the timeouts. |
|
@hetanthakkar1 I merged master for you so that we can check CI. Code changes look OK though if no tests fail for this and need updating, we probably should add some. |
|
jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4582/ |
Okay got it! Thanks |
Ohkayy. Thanks @myasonik ! |
cchaos
left a comment
There was a problem hiding this comment.
Thanks for getting this one started @hetanthakkar1 . There's still some more tasks to complete before we can merge this PR. We usually track these by the checklist that comes pre-filled in the PR summaries, so be sure not to delete that when creating PR's. I've added it back in to your PR summary and crossed off the unapplicable ones.
Since we're now conditionally rendering description we also need to mark the prop as optional. And since this is a pretty major change to the component, we should update at least one of the examples under the Custom children section. Probably just remove the description from the middle (form) one.
Also, as @myasonik suggested, we'll need a test for this as well. You can find the associated testing file ending in test.ts
CHANGELOG.md
Outdated
| - Removed static `id` from `EuiQuickSelectPopover` ([#4543](https://github.com/elastic/eui/pull/4543)) | ||
| - Fixed support sever side rendering for `EuiDataGrid` ([#4540](https://github.com/elastic/eui/pull/4540)) | ||
|
|
||
| - Fixed redundant render caused in `EuiCard` when `description` is false ([#4546]https://github.com/elastic/eui/pull/4582) |
There was a problem hiding this comment.
| - Fixed redundant render caused in `EuiCard` when `description` is false ([#4546]https://github.com/elastic/eui/pull/4582) | |
| - Made `description` prop of `EuiCard` optional ([#4546]https://github.com/elastic/eui/pull/4582) | |
There was a problem hiding this comment.
This CL entry also now has to move up to the top section under master
Do we want to? I kinda like keeping it required with allowing a |
|
If we go that route, then I think we at least need to be explicit about the boolean case in the prop types and add a prop comment explaining it. |
|
We talked about this in our weekly sync. Since the basic idea here is still wanting to require a |
…scription' as the missing field instead of 'children'
|
@hetanthakkar1 I've pushed a couples commits to make I verified with: |
|
👍 Yup makes sense to me! I'd still also like to see an update to that middle example under |
This comment has been minimized.
This comment has been minimized.
|
@hetanthakkar1 I've commented on your other PR. We try to keep questions/conversations in their respective PR's and issues just to make it easy to follow in the future. |
|
@cchaos I have removed that middle example. Could you please review it |
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4582/ |
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4582/ |
cchaos
left a comment
There was a problem hiding this comment.
@hetanthakkar1 I've updated this PR to fix more of the checklist items. 👍 From design.
@chandlerprall can you do a pass on the TS?
chandlerprall
left a comment
There was a problem hiding this comment.
Everything looks good, have one small recommendation.
|
I have made the necessary changes. Could you please review it |
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4582/ |
|
@cchaos could you merge it |
Just waiting on @chandlerprall's final review from the change he requested. |
|
I re-checked through the changes including the aria stuff. Looks good to me. I'll rerun Jenkins one more time then merge |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4582/ |


This conditional rendering will prevent redundant render caused when description in EuiCard is false
Checklist
[ ] Checked for breaking changes and labeled appropriately