Skip to content

fix(headings): copies heading link to clipboard#4805

Merged
kmcfaul merged 4 commits intopatternfly:mainfrom
srambach:4370-heading-copy-link
Oct 9, 2025
Merged

fix(headings): copies heading link to clipboard#4805
kmcfaul merged 4 commits intopatternfly:mainfrom
srambach:4370-heading-copy-link

Conversation

@srambach
Copy link
Member

Fixes #4370

This changes the link icon next to the headings to copy the link to the clipboard (and show a tooltip indicating this) rather than linking to the anchor.

@srambach srambach requested review from a team, dlabaj, edonehoo, mcoker and rebeccaalpert and removed request for a team September 26, 2025 17:47
@patternfly-build
Copy link
Collaborator

patternfly-build commented Sep 26, 2025

Preview: https://pf-org--pr-4805-site.surge.sh

Copy link
Member

@rebeccaalpert rebeccaalpert left a comment

Choose a reason for hiding this comment

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

Copying looks fine, but the description of the ticket doesn't mention dropping the link functionality (at least to me). Do we want to maintain it also? This PR drops it completely.

@srambach
Copy link
Member Author

Copying looks fine, but the description of the ticket doesn't mention dropping the link functionality (at least to me). Do we want to maintain it also? This PR drops it completely.

Consensus seems to be it doesn't make too much sense to jump, since you are already there. Other design systems seem to jump or copy the link but not both. The only use case we could think of is to scroll to an exact position for comparison across browser tabs, which seems like a pretty niche use case. I'm going to leave it off for now and if requested we can consider adding it in the future.

Copy link
Member

@rebeccaalpert rebeccaalpert left a comment

Choose a reason for hiding this comment

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

Works for me then!

@edonehoo
Copy link
Collaborator

this looks great!

It looks like the tooltip goes back to the hover message before it dismisses. Idk if that's just me or just a quirk to put up with, but wanted to mention

Screen.Recording.2025-09-29.at.4.40.05.PM.mov

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

Nice! Left a couple of comments.

import React from 'react';
import { Flex, FlexItem, Content } from '@patternfly/react-core';
import React, { useState } from 'react';
import { Flex, FlexItem, Content, Tooltip, Button } from '@patternfly/react-core';
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't look like <Button> is being used anywhere. Though the styles are pretty similar to the no-padding button, you could use it below. No padding button increases the click area with a negative inset via --#{$button}--m-plain--m-no-padding--border--offset if you want to match it what's in this PR

Comment on lines +23 to +25
console.log('URL copied to clipboard:', url);
}).catch(err => {
console.error('Failed to copy URL:', err);
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably want to take the console.logs out?

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

Nice! Left a couple of comments, but also when you hover/focus the button it says "copy link to clipboard," then says "link copied to clipboard" when you click on it, and if you don't click on anything else, the tooltip changes back to "copy link to clipboard" before disappearing. You may look into the code editor header under our examples to see how it handles the popover because it doesn't do that. It goes from "copy code to clipboard" to "code copied", then just disappears. You could also match that wording - "copy link to clipboard" and "link copied"

Copy link
Contributor

@dlabaj dlabaj left a comment

Choose a reason for hiding this comment

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

Other then cokers comments LGTM.

Copy link
Member

@rebeccaalpert rebeccaalpert left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Collaborator

@edonehoo edonehoo left a comment

Choose a reason for hiding this comment

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

💖 hooray!

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

🐤

@kmcfaul kmcfaul merged commit 227be4c into patternfly:main Oct 9, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

7 participants