CSE Machine : Stepper full screen NOT working FIX#3900
Conversation
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WalkthroughSideContentCseMachineBase adds a ChangesSlider Remounting Fix for Fullscreen CSE Machine
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/commons/sideContent/content/SideContentCseMachine.tsx`:
- Around line 188-196: The nested requestAnimationFrame in
handleFullscreenChange (and the other similar double-rAF call sites that set
sliderKey) can fire after unmount and call setState; fix by adding a helper
(e.g., scheduleDoubleRaf or scheduleRaf) that calls requestAnimationFrame twice,
stores the returned rAF ids in an array on the instance, and returns a cancel
token; call this helper from handleFullscreenChange and the other call site(s)
instead of raw rAFs, implement componentWillUnmount to iterate stored ids and
cancelAnimationFrame for each (and clear the array), and ensure any canceled
scheduled callbacks do not call setState after unmount.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c88eaa04-6a53-464f-ae51-575d4743d4d3
📒 Files selected for processing (1)
src/commons/sideContent/content/SideContentCseMachine.tsx
| private handleFullscreenChange = () => { | ||
| // Double rAF ensures the browser has completed layout after the fullscreen | ||
| // transition before Blueprint Slider remounts and measures its track width. | ||
| requestAnimationFrame(() => { | ||
| requestAnimationFrame(() => { | ||
| this.setState(prev => ({ sliderKey: prev.sliderKey + 1 })); | ||
| }); | ||
| }); | ||
| }; |
There was a problem hiding this comment.
Cancel queued remount callbacks on unmount.
The nested requestAnimationFrame callbacks can still run after unmount and call setState. Track rAF ids and cancel them in componentWillUnmount (and reuse one helper for both call sites).
Proposed fix
class SideContentCseMachineBase extends Component<CseMachineProps, State> {
+ private sliderRemountRaf1: number | null = null;
+ private sliderRemountRaf2: number | null = null;
+
+ private scheduleSliderRemount = () => {
+ this.sliderRemountRaf1 = requestAnimationFrame(() => {
+ this.sliderRemountRaf2 = requestAnimationFrame(() => {
+ this.setState(prev => ({ sliderKey: prev.sliderKey + 1 }));
+ });
+ });
+ };
private handleFullscreenChange = () => {
- // Double rAF ensures the browser has completed layout after the fullscreen
- // transition before Blueprint Slider remounts and measures its track width.
- requestAnimationFrame(() => {
- requestAnimationFrame(() => {
- this.setState(prev => ({ sliderKey: prev.sliderKey + 1 }));
- });
- });
+ // Double rAF ensures layout settles before Slider remount/re-measure.
+ this.scheduleSliderRemount();
};
componentWillUnmount() {
this.handleResize.cancel();
window.removeEventListener('resize', this.handleResize);
document.removeEventListener('fullscreenchange', this.handleFullscreenChange);
+ if (this.sliderRemountRaf1 !== null) cancelAnimationFrame(this.sliderRemountRaf1);
+ if (this.sliderRemountRaf2 !== null) cancelAnimationFrame(this.sliderRemountRaf2);
if (!this.isJava()) {
CseMachine.resetArrowOriginFilters();
}
}
componentDidUpdate(prevProps: {
@@
- requestAnimationFrame(() => {
- requestAnimationFrame(() => {
- this.setState(prev => ({ sliderKey: prev.sliderKey + 1 }));
- });
- });
+ this.scheduleSliderRemount();
}
}Also applies to: 205-209, 236-242
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/commons/sideContent/content/SideContentCseMachine.tsx` around lines 188 -
196, The nested requestAnimationFrame in handleFullscreenChange (and the other
similar double-rAF call sites that set sliderKey) can fire after unmount and
call setState; fix by adding a helper (e.g., scheduleDoubleRaf or scheduleRaf)
that calls requestAnimationFrame twice, stores the returned rAF ids in an array
on the instance, and returns a cancel token; call this helper from
handleFullscreenChange and the other call site(s) instead of raw rAFs, implement
componentWillUnmount to iterate stored ids and cancelAnimationFrame for each
(and clear the array), and ensure any canceled scheduled callbacks do not call
setState after unmount.
Description
Closes #3820. The stepper now works as intended!
Type of change
How to test
Test using the given code at #3820.
Checklist