Skip to content

Commit aee5c0b

Browse files
authored
Merge pull request #3795 from Jatin24062005/Fixing-Inconsistent-Behavior-of-Play-Sketch-Button
updating ideView to avoiding the inconsistency
2 parents 64a5f29 + 6d5f0a3 commit aee5c0b

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

client/modules/IDE/pages/IDEView.jsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import IDEOverlays from '../components/IDEOverlays';
2828
import useIsMobile from '../hooks/useIsMobile';
2929
import Banner from '../components/Banner';
3030
import { P5VersionProvider } from '../hooks/useP5Version';
31+
import { stopSketch } from '../actions/ide';
3132

3233
const BANNER_DISMISS_KEY = 'bannerLastDismissedAt';
3334
const BANNER_COOLDOWN_MINUTES = 30;
@@ -158,6 +159,17 @@ const IDEView = () => {
158159
}
159160
};
160161
}, [shouldAutosave, dispatch]);
162+
const prevIsMobile = useRef(isMobile);
163+
164+
useEffect(() => {
165+
if (prevIsMobile.current !== isMobile) {
166+
prevIsMobile.current = isMobile;
167+
168+
if (ide.isPlaying) {
169+
dispatch(stopSketch());
170+
}
171+
}
172+
}, [isMobile, ide.isPlaying, dispatch]);
161173

162174
useEffect(() => {
163175
const updateInnerWidth = (e) => {

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
"@types/react-helmet": "^6.1.11",
151151
"@types/react-responsive": "^8.0.8",
152152
"@types/react-router-dom": "^5.3.3",
153-
"@types/react-tabs": "^2.3.1",
153+
"@types/react-tabs": "^2.3.4",
154154
"@types/react-transition-group": "^4.4.12",
155155
"@types/sinon": "^17.0.4",
156156
"@types/styled-components": "^5.1.34",

0 commit comments

Comments
 (0)