curriculum icon indicating copy to clipboard operation
curriculum copied to clipboard

Fetching Data In React: code redactor is loading unreponsibly

Open Stan-tab opened this issue 6 months ago • 8 comments

Checks

Describe your suggestion

Code editor is loading while the main page is already loaded. The issue is when I read the article i accidentaly go to the part of code editor when it finishes loading and it is really unconvenient. P.s. if you find out how to solve it can u respond to me, just for academic knowledge

Path

Other / NA

Lesson Url

https://www.theodinproject.com/lessons/node-path-react-new-fetching-data-in-react

(Optional) Discord Name

No response

(Optional) Additional Comments

Have a nice day

Stan-tab avatar Jun 22 '25 08:06 Stan-tab

From what I could figure out codesandbox uses a focus() in its editor, which makes sense in the regular context of using a codesandbox, but in the case of using it in the iframe it will cause this automatic jumping to focus the input. There were no options I could find within iframe or codesandbox optional params to disable this behavior. As far as I can tell it's just the intended behavior of codesandbox.

joayo13 avatar Jun 23 '25 16:06 joayo13

Thanks for making this issue!

Yeah..... that doesn't make for a great experience.

@joayo13 would you have any interest in looking into this further? No pressure to do so, but if you'd like to I'm happy to assign you. If you can't find anything even after digging into it more we can always unassign you of course 🙂

wise-king-sullyman avatar Jun 26 '25 21:06 wise-king-sullyman

@wise-king-sullyman Yes, I'd be glad to do a deeper dive!

joayo13 avatar Jul 03 '25 15:07 joayo13

@joayo13 assigned, thank you!

wise-king-sullyman avatar Jul 03 '25 15:07 wise-king-sullyman

After doing some research, this behavior is only present with VM Sandboxes (formerly called Devboxes). The only solution I could come up with is for us to instead use the regular Sandboxes for our example.

We can even see that in their official docs for VM Sandboxes, it steals the input the same way with their embedded example. https://codesandbox.io/docs/learn/vm-sandboxes/embedding#embedding-vm-sandboxes

It's in beta right now so maybe in the future we'll get some more customization options.

joayo13 avatar Jul 08 '25 15:07 joayo13

This issue is stale because it has had no activity for the last 30 days.

github-actions[bot] avatar Aug 08 '25 02:08 github-actions[bot]

Going to merge https://github.com/TheOdinProject/curriculum/issues/28930 with this one by marking it as a duplicate of this, since they effectively are duplicates.

Will repost comment from there with edits

mao-sz avatar Nov 22 '25 22:11 mao-sz

Reposting from https://github.com/TheOdinProject/curriculum/issues/28930#issuecomment-3567100669

@wise-king-sullyman had a little look at docs and played around with VM sandboxes (formerly devboxes) and Browser sandboxes (what this issue is referring to as sandboxes).

We could technically run some of the basic React examples with a browser sandbox, they'd have to be made with create-react-app (now deprecated) and not the way our course does things with Vite. Note sure exactly what's different about react-scripts that allows it to use Webpack behind the scenes in the browser itself...but meh. Mainly though, embedded Browser sandboxes are still in beta and come with limitations like not being able to edit them without signing in. So that aspect isn't any different from the current VM sandboxes.

This hasn't really been a repeat issue raised in the community at all, for context.

Not sure on best approach. I'm not convinced Browser Sandboxes are the way forward - not a full fix. We could look at alternative sites we can embed e.g. Stackblitz, but I haven't the time to investigate that fully, so I have no idea how viable it'd be and whether it'd actually resolve the problems detailed in both issues.

mao-sz avatar Nov 22 '25 22:11 mao-sz