-
Notifications
You must be signed in to change notification settings - Fork 8
fix: Plotly jump on rerender in filling layouts #236
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3aeb744
Avoid showing Plotly FigureWidget before resize settles
cpsievert 3f77cc3
Narrow Plotly resize settle fix
cpsievert d97a136
Pass widget package to Plotly settle logic
cpsievert 41cdcc3
Move Plotly settle helpers into their own module
cpsievert a7b0709
Reveal non-Plotly widgets without waiting for settle
cpsievert 364c468
Restore non-Plotly reveal order
cpsievert 91ad308
Use Plotly render events instead of CSS selectors
cpsievert c377fa4
Rename Plotly reveal helper for clarity
cpsievert e2fa4f5
Make Plotly regression self-contained for CI
cpsievert 7792331
Use early return for non-Plotly outputs
cpsievert f308fe1
Apply fill-class hook before widget package split
cpsievert 266ebb1
Restore CSS selector Plotly discovery
cpsievert 37d5f30
Inline Plotly reveal helper call
cpsievert 33f1c7d
Document Plotly reveal fix in changelog
cpsievert 3433ae6
Apply remaining PR formatting feedback
cpsievert 40540d3
Address Copilot feedback on Plotly reveal flow
cpsievert b70985d
Fix Playwright test import ordering
cpsievert 05bddf5
Tighten Plotly review test coverage
cpsievert fa61960
Invalidate stale Plotly reveals on every render
cpsievert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| interface PlotlyEventEmitter { | ||
| on(eventName: string, callback: () => void): void; | ||
| once(eventName: string, callback: () => void): void; | ||
| removeListener(eventName: string, callback: () => void): void; | ||
| } | ||
|
|
||
| const plotlyAfterPlotTimeoutMs = 5000; | ||
|
|
||
| export function findPlotlyGraphDiv(root: HTMLElement): HTMLElement | null { | ||
| const plotlyEl = root.matches(".js-plotly-plot") | ||
| ? root | ||
| : root.querySelector(".js-plotly-plot"); | ||
| return plotlyEl instanceof HTMLElement ? plotlyEl : null; | ||
| } | ||
|
|
||
| export async function waitForPlotlyReadyToReveal( | ||
| plotEl: HTMLElement, | ||
| dispatchResize: () => void, | ||
| ): Promise<void> { | ||
| const plotly = (window as any).Plotly; | ||
| await waitForPlotlyAfterPlot(plotEl); | ||
|
|
||
| if (plotly?.Plots?.resize) { | ||
| try { | ||
| const afterResize = waitForPlotlyAfterPlot(plotEl); | ||
| await plotly.Plots.resize(plotEl); | ||
| await afterResize; | ||
| } catch (err) { | ||
| console.error("Error resizing Plotly widget before reveal:", err); | ||
| } | ||
|
cpsievert marked this conversation as resolved.
|
||
| } | ||
|
|
||
| dispatchResize(); | ||
| } | ||
|
cpsievert marked this conversation as resolved.
|
||
|
|
||
| function waitForPlotlyAfterPlot(plotEl: HTMLElement): Promise<void> { | ||
| return new Promise((resolve) => { | ||
| const handler = () => { | ||
| cleanup(); | ||
| resolve(); | ||
| }; | ||
|
|
||
| const cleanup = () => { | ||
| if (hasMethod<PlotlyEventEmitter, "removeListener">(plotEl, "removeListener")) { | ||
| plotEl.removeListener("plotly_afterplot", handler); | ||
| } | ||
| window.clearTimeout(timeoutId); | ||
| }; | ||
|
|
||
| const timeoutId = window.setTimeout(() => { | ||
|
cpsievert marked this conversation as resolved.
|
||
| cleanup(); | ||
| resolve(); | ||
| }, plotlyAfterPlotTimeoutMs); | ||
|
|
||
|
cpsievert marked this conversation as resolved.
|
||
| if (hasMethod<PlotlyEventEmitter, "once">(plotEl, "once")) { | ||
| plotEl.once("plotly_afterplot", handler); | ||
| return; | ||
| } | ||
|
|
||
| if (hasMethod<PlotlyEventEmitter, "on">(plotEl, "on")) { | ||
| plotEl.on("plotly_afterplot", handler); | ||
| return; | ||
| } | ||
|
|
||
| cleanup(); | ||
| resolve(); | ||
| }); | ||
| } | ||
|
|
||
| function hasMethod<T, K extends keyof T>( | ||
| x: unknown, | ||
| key: K, | ||
| ): x is T & Record<K, (...args: any[]) => unknown> { | ||
| return !!x && typeof (x as any)[key] === "function"; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.