-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
chore: move attachment link back to tree item, make it flash yellow #34353
base: main
Are you sure you want to change the base?
Changes from 8 commits
2162ade
2b74e52
269b0bb
b191773
879ba72
13d89e4
299a52e
5dcff8f
b75cf1f
05ca43b
34df343
ef9f0ff
b4d900f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,7 +148,7 @@ export const Workbench: React.FunctionComponent<{ | |
|
||
const revealAttachment = React.useCallback((attachment: AfterActionTraceEventAttachment) => { | ||
selectPropertiesTab('attachments'); | ||
setRevealedAttachment(attachment); | ||
setRevealedAttachment({ ...attachment }); // copy to force re-render | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not seeing why this clone is necessary, and in general causing rerenders in this manner is bad practice as it's difficult to track down why stuff is behaving as it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'll be passed to a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Revisiting this, you're right. Cloning an object is hard to debug because both objects will look the same. I've refactored it to use an incrementing counter instead. |
||
}, [selectPropertiesTab]); | ||
|
||
React.useEffect(() => { | ||
|
@@ -238,7 +238,7 @@ export const Workbench: React.FunctionComponent<{ | |
id: 'attachments', | ||
title: 'Attachments', | ||
count: attachments.length, | ||
render: () => <AttachmentsTab model={model} selectedAction={selectedAction} revealedAttachment={revealedAttachment} /> | ||
render: () => <AttachmentsTab model={model} revealedAttachment={revealedAttachment} /> | ||
}; | ||
|
||
const tabs: TabbedPaneTabModel[] = [ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -224,3 +224,16 @@ export function scrollIntoViewIfNeeded(element: Element | undefined) { | |||||
|
||||||
const kControlCodesRe = '\\u0000-\\u0020\\u007f-\\u009f'; | ||||||
export const kWebLinkRe = new RegExp('(?:[a-zA-Z][a-zA-Z0-9+.-]{2,}:\\/\\/|www\\.)[^\\s' + kControlCodesRe + '"]{2,}[^\\s' + kControlCodesRe + '"\')}\\],:;.!?]', 'ug'); | ||||||
|
||||||
// flash is retriggered whenever the value changes | ||||||
export function useFlash(flash: any | undefined) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the semantic? Whenever There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whenever There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This API signature should be You return a function that, when called, triggers the flash by updating state. You have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In particular it looks like you want your I believe you also trigger your There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How's that different from the current implementation, apart from the placement of the useEffect? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const [flashState, setFlashState] = React.useState(false); | ||||||
React.useEffect(() => { | ||||||
if (flash) { | ||||||
setFlashState(true); | ||||||
const timeout = setTimeout(() => setFlashState(false), 1000); | ||||||
return () => clearTimeout(timeout); | ||||||
} | ||||||
}, [flash]); | ||||||
return flashState; | ||||||
} |
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.
It seems like you can revert this back to be a boolean? I don't see why it should be different now with the yellow flash compared to scrolling into view.
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.
Just like with scrolling into view, we need this to be an ID object so we can retrigger the animation. I think there was a bug with scroll into view before, where it didn't retrigger when clicking the same button twice. But it wasn't as noticeable because you'd have to scroll around between clicking the button.