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

WSTEAM1-989: Live Post Share Button #11693

Merged
merged 62 commits into from
Jul 11, 2024

Conversation

emilysaffron
Copy link
Contributor

@emilysaffron emilysaffron commented Jun 3, 2024

Resolves JIRA https://jira.dev.bbc.co.uk/browse/WSTEAM1-989

Overall changes

Adds a Share button for Live page posts.

Code changes

  • Adds a Share button that uses the Share API with the URL to the current post
  • Adds logic in stream to determine whether the share buttons should be rendered
  • Adds functionality to focus on post title when visiting a shared url
  • Overrides cookie banner force focus behaviour for shared urls
  • Adds yarn dev-https script to use HTTPS locally via Next.js, as share API is only available in secure contexts, so testing on a local network with IP address will work.
  • Adds post query param for share link tracking
  • Adds unit tests

Testing

There are currently some a11y issues, which I haven't managed to find a fix for:

  • VoiceOver iOS, after exiting share window, VoiceOver takes over focus back to top of page, not respecting forced focus code
  • Sometimes Webkit browsers don't respect the code that automatically brings focus back to the share button that was clicked after the share prompt is closed, usually happens after tapping 2 or 3 share buttons
  1. Visit a live page
  2. Click share button

Helpful Links

Add Links to useful resources related to this PR if applicable.

Coding Standards

Repository use guidelines

@emilysaffron emilysaffron self-assigned this Jun 3, 2024
@HarveyPeachey HarveyPeachey self-assigned this Jul 2, 2024
<div ref={viewRef}>
<button type="button" ref={focusRef} onClick={handleShare} css={styles}>
<ShareSvg />
<span>Share</span>
Copy link

Choose a reason for hiding this comment

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

We might need role text around these 2 spans to mitigate text splitting as much as we can

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
Copy link

Choose a reason for hiding this comment

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

Missing focusable false

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

backgroundColor: 'transparent',
cursor: 'pointer',
'&:hover, &:focus-visible': {
border: `${pixelsToRem(2)}rem solid ${palette.BRAND_BACKGROUND}`,
Copy link

Choose a reason for hiding this comment

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

The focus outline doesn't work in Firefox (I see a dotted line), are we able to use our custom classes we already have for adding the focus indicator?

Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't to do with this styling, looks like firefox has an override style for type=button. I think we'll need to add type='button' to the custom classes

image

Copy link

Choose a reason for hiding this comment

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

Or we can remove type button, don't think it's strictly needed here.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's needed as browsers would treat it as a submit button for a form https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/button-has-type.md

Copy link

Choose a reason for hiding this comment

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

Believe that is only if it's wrapped inside a form tag... but cool

Copy link
Contributor

Choose a reason for hiding this comment

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

Apparently if you don't add it, it's possible that it can destroy the current state of the document https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#notes

Copy link
Contributor

Choose a reason for hiding this comment

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

I've done this now

span: {
verticalAlign: 'middle',
},
svg: {
Copy link

Choose a reason for hiding this comment

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

On hover or focus in Firefox when you change colour preferences (haven't checked WHC) you can't see the icon, are we able to fix this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've fixed this, however there seems to be an issue with Firefox and border colour of buttons, when colour overrides are turned on firefox enforces a grey coloured border, I've also tried using outline, and box shadow to override it, however they don't work:

image

Copy link

Choose a reason for hiding this comment

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

Are you able to apply styling as per the 'submit' button on uploader, that has an outline that looks ok as far as I can tell?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay messing around with trial and error, I've managed to get the colour of text to apply to the border. We actually need to fix the border on the submit button, as currently it's set to black and won't adjust to the users colour preference.

Copy link

Choose a reason for hiding this comment

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

Cna you raise a ticket for that please when you are done with this @HarveyPeachey

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes will do

@@ -7,7 +7,8 @@ const focusIndicator = ({ palette }: Theme) => css`
// Adds focus indicator styling to all a and button elements by default.
a:focus-visible,
button:focus-visible,
button[type='submit']:focus-visible {
button[type='submit']:focus-visible,
h3:focus-visible {
Copy link

Choose a reason for hiding this comment

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

Do we want this for all h3's across the site?

Copy link
Contributor

Choose a reason for hiding this comment

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

This should be fine as h3's aren't interactive elements, so they would only be able to be programmatically focused on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex#:~:text=Some%20focusable%20HTML,focus%20navigation%20order).

Copy link

Choose a reason for hiding this comment

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

Ok, was just checking that you meant to do this for all h3s

@@ -7,7 +7,8 @@ const focusIndicator = ({ palette }: Theme) => css`
// Adds focus indicator styling to all a and button elements by default.
Copy link

Choose a reason for hiding this comment

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

Comment out of date if adding h3

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

backgroundColor: palette.BRAND_BACKGROUND,
path: {
fill: palette.WHITE,
[mq.HIGH_CONTRAST]: {
Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes it is

export const HIGH_CONTRAST = `@media screen and (forced-colors: active)`;

Copy link

Choose a reason for hiding this comment

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

Great. Would be good if we could rename HIGH_CONTRAST to FORCE_COLOURS across the code base...

Copy link

@greenc05 greenc05 left a comment

Choose a reason for hiding this comment

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

Thanks very much @HarveyPeachey left a couple of comments

@HarveyPeachey HarveyPeachey merged commit 45159bf into latest Jul 11, 2024
11 checks passed
@HarveyPeachey HarveyPeachey deleted the WSTEAM1-1041-SPIKE-Web-Share-API branch July 11, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants