Open karlbaumhauer opened 2 months ago
Adding some additional context from our conversation and the initial task:
"doesn't break valid HTML (links inside links are not allowed :))".
Citing HTML specs for <a>
:
[...] there must be no interactive content descendant, a element descendant, or descendant with the tabindex attribute specified.
And here the list of interactive elements:
Interactive content is content that is specifically intended for user interaction.
Here are some useful resources on links on cards:
Currently we're clearly violating specs here, so let's see, what the solution will be. :)
I just created a proposal, how this could work out in future without violating specs and a11y: https://codepen.io/mariohamann/full/wvLjdLr
@christophsaile helped me testing it and so far it looks good!
I would propose that we let test this in the accessibility audit instead of the other template.
@mariohamann a possible improvement could be that button/link also receives focus state when the focus on the card is active. See last example here: https://codepen.io/aardrian/pen/vYOGpXb. This way it is more clear that the card and the button / link are the same interaction
This solution is definitely an improvement, but it's not perfect. The good news is there is no perfect solution. That pattern is still an unsolved problem.
My two cents:
tabindex=-1
and aria-hidden=true
on interactive elements is generally not the best idea.You can address my first three concerns by using a pseudo-element instead. See this CodePen for a demo.
sd-teaser{
position: relative;
margin: 8px;
transform: translate(0); /* creates a new stacking context */
}
sd-button::part(base)::before {
position: fixed;
inset: 0;
display: block;
content: "";
}
If you want to make certain parts selectable or if they include other interactive elements, you can promote them to the top layer on the z-axis.
p {
position: relative;
z-index: 1;
}
Why don’t we just go with solution 6 / pseudo element here?
https://codepen.io/matuzo/pen/ZEqbXOM
Seems to be the best option.
It would have to be adapted a little in the example so that both links are clickable.
The link would still need position: relative
and a z-index
, then it is also clickable
Current behavior
Caused by the need of several teams, we added a sample which shows the teaser where the teaser itself is a clickable element AND it contains another clickable element.
=> https://solid-design-system.fe.union-investment.de/x.x.x/storybook/?path=/story/components-sd-teaser--samples-clickable
With this sample of the teaser we currently have 2 issues:
Expected behavior
Regarding 2.2. => expected behavior needs to be defined by UX
Steps to reproduce
Technical Information
This topic has been part of a PR and the respective ticket in January but unfortunately, we did not write down any summary from our discussions we had.
DoR
DoD
feature
branch