Fix (Saving Images): Fixed a window proxy issue when saving images in the micro-frontend framework. #21391
+20
−1
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.
Fix (Saving Images)
Added the
pickEventViewfunction to handle the window proxy issue in the micro-frontend framework, ensuring that the save image event is triggered correctly in different environments.Brief Information
This pull request is in the type of:
What does this PR do?
This PR fixes an issue where the save image functionality failed in micro-frontend environments due to window proxy interference. The introduced
pickEventViewfunction correctly identifies the appropriate view context for event handling, ensuring consistent behavior across different sandboxed or proxy-ed window environments.Fixed issues
Details
Before: What was the problem?
In micro-frontend architectures (e.g., using Module Federation or iframe-based isolation), the
windowobject is often proxied or sandboxed. When triggering the save image event, the originalwindowreference was used directly, leading to failures in event dispatching or incorrect DOM context resolution. This caused the save image feature to be non-functional or inconsistent across environments.After: How does it behave after the fixing?
With the addition of the
pickEventViewutility function, the system now dynamically resolves the correct view context (e.g., the actualwindowordocumentfrom the current execution context) before triggering the save image event. This ensures the event is properly dispatched and handled regardless of the micro-frontend sandboxing mechanism. The save image functionality now works reliably in all supported environments, including isolated or proxied frames.Document Info
One of the following should be checked.
Other information
This fix is particularly important for users adopting ECharts in micro-frontend setups using tools like Webpack Module Federation, Single-SPA, Micro-App, or custom sandboxing solutions. The
pickEventViewfunction is designed to be lightweight and reusable across similar contexts.