-
Notifications
You must be signed in to change notification settings - Fork 575
added copy to clipboard feature on trace id #2815
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
Conversation
@Darshit42 As per the contributing guidelines, all commits need to be signed, this ensures compliance with the DCO. Also, please review the checklist and ensure that all relevant items are properly checked off. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- the proposal as to create a dedicated "click to copy" component so that we can reuse it in more than one place
- include the screenshots in the PR description
setHasCopied(true); | ||
setTimeout(() => { | ||
setHasCopied(false); | ||
}, 2000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this works but it's an unstable way to implement this. If I click the link again 1.9s after the first time, then "copied" text will disappear in 0.1s instead of 2s. A more robust way to do it is
- whenClick stores a deadline timestamp in a state (such that later click will override it to later timestamp): deadline=time.Now + 1.8sec
- whenClick kicks of a timeout function
- timeout function checks if the current time >= deadline, then it sets copied=false, otherwise it doesn't do that
Another solution is to cancel old timeout when new one is created, but I think it's even harder to implement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before pushing new commit, sign the old commit please. |
@Parship999 @yurishkuro I have made the changes, I also changed test cases to fit the new component, to be honest I wrote/changed test cases for first time if you can tell me how to improve them please let me know :) |
thanks for the advice I will do it :) Edit-- by sign them do you mean tick the checklist? I did run the tests before pushing |
|
@yurishkuro @Parship999 I think they are now signed I ran this command |
You can see the DCO check failing in CI checks. git amend only affects the latest commits, but the check expects all of them signed. Usually the easiest way is to manually squash all commits and sign the latest, but it gets complicated if you did multiple merge-main in between. |
faf0cb7
to
af3be5e
Compare
|
||
return ( | ||
<Tooltip title={isCopied ? 'Copied to clipboard' : 'Copy to clipboard'}> | ||
<span className={className} onClick={whenClicked} role="textbox" tabIndex={0}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The role="textbox"
attribute is semantically incorrect for this element since it doesn't accept text input. Consider using role="button"
instead, which better represents the element's copy action functionality. Additionally, adding an aria-label
attribute (e.g., aria-label="Copy trace ID to clipboard"
) would improve accessibility by clearly communicating the element's purpose to screen reader users.
<span className={className} onClick={whenClicked} role="textbox" tabIndex={0}> | |
<span className={className} onClick={whenClicked} role="button" aria-label="Copy to clipboard" tabIndex={0}> |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
|
||
return ( | ||
<Tooltip title={isCopied ? 'Copied to clipboard' : 'Copy to clipboard'}> | ||
<span className={className} onClick={whenClicked} role="textbox" tabIndex={0}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component is keyboard accessible with tabIndex={0}
but doesn't handle keyboard interactions. For full accessibility, please add keyboard event handling for Enter and Space keys:
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
whenClicked();
}
}}
This ensures users navigating with keyboards can also trigger the copy functionality.
<span className={className} onClick={whenClicked} role="textbox" tabIndex={0}> | |
<span className={className} onClick={whenClicked} onKeyDown={(e) => { | |
if (e.key === 'Enter' || e.key === ' ') { | |
e.preventDefault(); | |
whenClicked(); | |
} | |
}} role="textbox" tabIndex={0}> |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
@@ -66,12 +72,13 @@ describe('TraceIdDisplayLength', () => { | |||
getConfigValue.mockReturnValue(configuredLength); | |||
|
|||
wrapper = createWrapper({ traceId: shortTraceId }); | |||
expect(wrapper.text()).toEqual(shortTraceId); | |||
expect(wrapper.find('ClickToCopy').children().text()).toEqual(shortTraceId); | |||
}); | |||
|
|||
it('renders when traceId is undefiend', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a typo in the test description: undefiend
should be undefined
.
it('renders when traceId is undefiend', () => { | |
it('renders when traceId is undefined', () => { |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
please sign all commits |
a789032
to
41ef276
Compare
<span | ||
className={`TraceIDLength ${lengthClass} u-tx-muted ${className}`} | ||
onClick={whenClicked} | ||
role="button" | ||
tabIndex={0} | ||
> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component correctly implements visual accessibility with role="button"
and tabIndex={0}
, but is missing keyboard event handling. For full accessibility compliance, please add an onKeyDown
handler to support activation via keyboard (Enter or Space key):
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
whenClicked();
}
}}
This ensures the component is fully accessible to keyboard-only users, which is an important WCAG requirement.
<span | |
className={`TraceIDLength ${lengthClass} u-tx-muted ${className}`} | |
onClick={whenClicked} | |
role="button" | |
tabIndex={0} | |
> | |
<span | |
className={`TraceIDLength ${lengthClass} u-tx-muted ${className}`} | |
onClick={whenClicked} | |
onKeyDown={(e) => { | |
if (e.key === 'Enter' || e.key === ' ') { | |
whenClicked(); | |
} | |
}} | |
role="button" | |
tabIndex={0} | |
> |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
@yurishkuro I tried signing them but i think its hard due to different commits between my commits, can I close this and open a new pr with all commits signed? |
@yurishkuro I just saw another pr has been merged regarding this issue I am sorry for delay, I understand as this was a minor issue and was going on for days, should I close this pr? |
Nope, That was not merged in jaeger-ui. This issue open from a week now. So, if you don't like to work on this or having trouble than also let us know. Thanks. |
@Darshit42 you can open a new PR and reference this one |
I am closing this PR as I am opening another PR |
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger
:make lint test
jaeger-ui
:npm run lint
andnpm run test