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

Rework clickable cards using CSS invisible overlay rather than JS event handler #762

Merged
merged 17 commits into from
Oct 10, 2022

Conversation

andymantell
Copy link
Contributor

@andymantell andymantell commented Aug 3, 2021

Description

Rework clickable cards using CSS invisible overlay rather than JS event handler

This avoids problems with using Ctrl-click, middle click, right click to open new tabs since the link just behaves as it would natively

Fixes #758
Fixes #749

Checklist

Issues observed during browser testing

  • IE10 - image is not clickable in "card with an image" example. Ignoring, because IE10 is not supported and the experience is ok.
    Fixed. Don't know whether we want IE10 fixes lingering around, but it's relatively inoffensive, so might not hurt to have it for a while? Easily removed if we don't want it...

…nt handler

This avoids problems with using Ctrl-click, middle click, right click
to open new tabs since the link just behaves as it would natively

Fixes #758
Fixes #749
@andymantell andymantell changed the title Rework clickable cards using CSS invisible overlay rather than JS eve… Rework clickable cards using CSS invisible overlay rather than JS event handler Aug 3, 2021
@andymantell andymantell marked this pull request as ready for review August 3, 2021 14:32
color: $nhsuk-focus-text-color;
}
.nhsuk-card__heading a,
.nhsuk-card__link {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chrimesdev I've put both these selectors in here in order to be consistent with what came before. Is this still necessary? I assume it's backwards compatibility before the .nhsuk-card__link class was added

@andymantell andymantell requested a review from chrimesdev August 3, 2021 14:34
@chrimesdev
Copy link
Member

@Fenwick17 as you did the original work with the clickable Card, are you OK to take a look at this? I'll also give it a review

@Fenwick17
Copy link
Contributor

Spotted one issue that occurs with MacOS Hover Text.
The large-text view does not work for the content of the card due to the overlay, hovering the heading will display the large-text view, but not the body content.

Everything else appears to be working as you would expect.

@andymantell
Copy link
Contributor Author

andymantell commented Aug 5, 2021

Thanks @Fenwick17 - do you mean these ones?

image

@andymantell
Copy link
Contributor Author

Sorry, I see what you mean now. Using https://support.apple.com/en-gb/guide/mac-help/mchlb203bc78/mac

Let me have a think about this 🤔

@Fenwick17
Copy link
Contributor

Fenwick17 commented Aug 5, 2021

Added a gif of the issue, if it can't be resolved we will have to make a decision on whether it is acceptable as it is.
I would image any Windows software that does this would have a similar behaviour.

I believe NVDA with mouseover will also not read the body content due to the overlay, but I haven't tested that yet.

Hover text not display on hover

@andymantell
Copy link
Contributor Author

yeah makes sense. I'm on windows so I'll see if there's anything similar here. And will have a think if there's anything sensible can be done

@andymantell
Copy link
Contributor Author

@chrimesdev @Fenwick17 I'm not sure what to do about this. Surely anything that alters what HoverText "sees" would also affect what a screenreader sees. So if we start changing things for HoverText, we would negatively affect other tools.

I don't know if a perfect solution exists for this then. I think we're stuck choosing between two slightly imperfect solutions:

  1. Go back to the JS way of doing this, and try and enhance it for more ways to open new tabs (Ctrl-Click, middle click etc). This will never catch all the ways though (right click / long press on mobile to open new tab from the context menu for example)

  2. Go with the invisible overlay, and accept the hovertext deficiency.

Any thoughts? Have I missed any other options?

@Fenwick17
Copy link
Contributor

Fenwick17 commented Sep 22, 2021

I just performed some Browserstack testing and didn't spot any issues with the CSS only solution.
So the only issues we seem to have are not being able to copy text and no hover text on the paragraph.

For both of these I personally don't think they are show stoppers.
The text is meant to just be a little bit of extra context so there shouldn't really be a need to copy it.
The link itself ideally should be clear enough for a user to know what it means without needing the additional text and standard zoom behaviour will still work as a fallback.

The only thing that comes to mind at the moment is if we add visually hidden content to the link itself, so that it will show up with Hover Text.

<a class="nhsuk-card__link" href="./pages/examples.html">
  Examples<span class="nhsuk-u-visually-hidden">: Page layouts, text pages and components</span>
</a>

Then you would have to use aria-hidden on the <p>.
This is probably wildly overkill but I thought it was a cool workaround.

What do you think? Overall, I think we can proceed with what Andy has done.

@chrimesdev chrimesdev requested review from Fenwick17 and removed request for chrimesdev October 21, 2021 08:54
@chrimesdev chrimesdev removed their assignment Oct 21, 2021
@chrimesdev
Copy link
Member

@Fenwick17 as you have done more work on this than I have, I am happy to go with what you think is best.

Copy link
Contributor

@Fenwick17 Fenwick17 left a comment

Choose a reason for hiding this comment

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

Happy to move forward with this implementation

@chrimesdev
Copy link
Member

chrimesdev commented Oct 21, 2021

@andymantell do you think this needs a little more information in the CHANGELOG around removing the JavaScript for the Card component? If anyone is importing and initialising the Card using ES6 and we have now removed it, would it be a breaking change rather than a fix?

@andymantell
Copy link
Contributor Author

@chrimesdev Agreed. Done - moved it to 6.0.0 and added a note about removing JS

@chrimesdev
Copy link
Member

Thanks Andy, as this is a breaking change we will hold off merging this PR and merge/release with #740

@andymantell andymantell requested a review from DomBaker December 15, 2021 12:01
Copy link
Contributor

@DomBaker DomBaker left a comment

Choose a reason for hiding this comment

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

Reviewed and approved. ready for v7.0.0 of frontend library, date for this is unconfirmed

@wa-rren-dev wa-rren-dev changed the base branch from master to alpha-v7 August 25, 2022 10:00
Tabs tests - Initial dom setup
# Conflicts:
#	CHANGELOG.md
#	packages/components/card/card.js
#	packages/components/card/card.scss
#	packages/nhsuk.js
@wa-rren-dev wa-rren-dev merged commit 8564a7c into alpha-v7 Oct 10, 2022
@wa-rren-dev wa-rren-dev deleted the feature/rework-clickable-cards branch October 10, 2022 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants