-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
report(flow): fix report anchors #13233
Changes from 1 commit
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 | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -28,27 +28,32 @@ export function convertChildAnchors(element: HTMLElement, index: number) { | |||||||||||||||||||
|
||||||||||||||||||||
const nodeId = link.hash.substr(1); | ||||||||||||||||||||
link.hash = `#index=${index}&anchor=${nodeId}`; | ||||||||||||||||||||
link.onclick = e => { | ||||||||||||||||||||
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 would expect the new-ish report click handler to end up doing the same thing.. lighthouse/report/renderer/report-renderer.js Lines 177 to 185 in 362f376
but it doesnt? 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. With the flow report, the This would also work if we didn't convert all the link |
||||||||||||||||||||
e.preventDefault(); | ||||||||||||||||||||
const el = document.getElementById(nodeId); | ||||||||||||||||||||
if (el) el.scrollIntoView(); | ||||||||||||||||||||
}; | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
export const Report: FunctionComponent<{currentLhr: LH.FlowResult.LhrRef}> = | ||||||||||||||||||||
({currentLhr}) => { | ||||||||||||||||||||
export const Report: FunctionComponent<{hashState: LH.FlowResult.HashState}> = | ||||||||||||||||||||
({hashState}) => { | ||||||||||||||||||||
const {dom, reportRenderer} = useReportRenderer(); | ||||||||||||||||||||
const ref = useRef<HTMLDivElement>(null); | ||||||||||||||||||||
|
||||||||||||||||||||
useLayoutEffect(() => { | ||||||||||||||||||||
if (ref.current) { | ||||||||||||||||||||
dom.clearComponentCache(); | ||||||||||||||||||||
reportRenderer.renderReport(currentLhr.value, ref.current); | ||||||||||||||||||||
convertChildAnchors(ref.current, currentLhr.index); | ||||||||||||||||||||
reportRenderer.renderReport(hashState.currentLhr, ref.current); | ||||||||||||||||||||
convertChildAnchors(ref.current, hashState.index); | ||||||||||||||||||||
const topbar = ref.current.querySelector('.lh-topbar'); | ||||||||||||||||||||
if (topbar) topbar.remove(); | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
return () => { | ||||||||||||||||||||
if (ref.current) ref.current.textContent = ''; | ||||||||||||||||||||
}; | ||||||||||||||||||||
}, [reportRenderer, currentLhr]); | ||||||||||||||||||||
}, [reportRenderer, hashState]); | ||||||||||||||||||||
|
||||||||||||||||||||
return ( | ||||||||||||||||||||
<div ref={ref} className="lh-root" data-testid="Report"/> | ||||||||||||||||||||
|
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.
Should have been designed this way initially, so changes to multiple hash params are handled in the same render.