Skip to content

Add PrintContext - #244

Merged
abhithesys merged 4 commits into
mainfrom
abhishek/print-context
Dec 23, 2025
Merged

Add PrintContext#244
abhithesys merged 4 commits into
mainfrom
abhishek/print-context

Conversation

@abhithesys

Copy link
Copy Markdown
Contributor

For printing a component several changes might be required like changing layout, hide something, reveal hidden elements.

This change adds PrintContext, which devs can use to tell components that they are being printed.
All the chart animations have been disabled, when in print context.

Comment on lines +292 to +301
// Read initial dimensions synchronously before first paint to avoid size jump
useLayoutEffect(() => {
const wrapper = wrapperRef.current;
if (!wrapper) return;

const rect = wrapper.getBoundingClientRect();
setWrapperRect({ width: rect.width, height: rect.height });
}, []);

// Use ResizeObserver for subsequent size changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why are we doing this ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and if so why not do the same for radial chart ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am using useLayoutEffect to set the wrapper size. This reduces the flickering of the chart.

  1. Moved the logic to the place we are using resize observer.
  2. Added the same to radar chart

@ankit-thesys ankit-thesys left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LG

@abhithesys
abhithesys merged commit b267556 into main Dec 23, 2025
3 checks passed
@abhithesys
abhithesys deleted the abhishek/print-context branch December 23, 2025 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants