Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The live js editor can go up to 2 levels of scrollbars #2053

Closed
JSmithOner opened this issue Mar 21, 2022 · 6 comments
Closed

The live js editor can go up to 2 levels of scrollbars #2053

JSmithOner opened this issue Mar 21, 2022 · 6 comments
Labels
idle Issues and pull requests with no activity for three months.

Comments

@JSmithOner
Copy link

When using the javascript editor with long code and long console outputs, the overflows are a bit messy, as shown on the picture.

live editor

I was thinking of editing the style and perhaps html to make it more clear and most important get rid of the first level scrollbars ( the outer ones ). Only problem is I can't find the code in the repo. If anyone could tell me if I can make an edit of this editor and then after make a pull request. Thanks in advance.

@welcome
Copy link

welcome bot commented Mar 21, 2022

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it.

@wbamberg
Copy link
Contributor

@JSmithOner , I don't see the outer scrollbar in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map , do you have steps to reproduce for it?

@wbamberg
Copy link
Contributor

(This does happen sometimes though, we have an issue for it at mdn/bob#730 . So I'm not suggesting it's not a problem, just that I don't see it in this particular case.)

@JSmithOner
Copy link
Author

@wbamberg Thank you for your answer, I often use this editor to quickly test algorithms so I guess the problem don't appear with the mdn examples. Also I've been trying to clone the repo to fix this bug but looks like the editor is integrated via a sort of embedded component. Didn't took time to understand how it worked but couldn't reproduce the issue locally. The error don't occur locally because the editor fits the window's width also I guess the editor on the web is wrapped inside a div that allows overflow and maybe don't have a max width that allows container to fits it's parent div. What do you think?

@wbamberg
Copy link
Contributor

wbamberg commented Mar 30, 2022

The JS examples get built into an editor by the mdn/bob package. This creates an editor in one of three different heights: small, medium, large, depending on the length of the example in lines. The editors get published as standalone pages. For example, here's the example for Array.slice(), which is a large example: https://interactive-examples.mdn.mozilla.net/pages/js/string-slice.html .

To embed them in MDN pages we use a macro, {{EmbedLiveSample}}. That macro creates an iframe whose contents is the standalone page that the example is in.

Because it's an iframe, we need to say how big we want the iframe to be. So the macro has to pass an extra argument if it wants to embed a small or large example (medium size is the default). So you'll see that in the page for Array.slice() we pass "taller" into the macro. So we get an iframe that fits. If we forget to do that we either get some extra whitespace at the bottom (the iframe is too big) or a vertical outer scrollbar (the iframe is too small).

So that's AFAIK roughly how sizing works for interactive examples. It's a bit fragile but can be made to work OK. I'm not sure how it relates to your issue (or if there even is an issue here for MDN at all?).

@github-actions github-actions bot added the idle Issues and pull requests with no activity for three months. label Dec 22, 2022
@NiedziolkaMichal
Copy link
Member

This is now fixed. A lot of content in the JS example looks like this:
image

Thanks a lot for reporting this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idle Issues and pull requests with no activity for three months.
Projects
Development

No branches or pull requests

3 participants