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

JS example editor output doesn't wrap, makes the whole iframe scroll #272

Closed
wbamberg opened this issue Jun 13, 2019 · 6 comments · Fixed by #1137
Closed

JS example editor output doesn't wrap, makes the whole iframe scroll #272

wbamberg opened this issue Jun 13, 2019 · 6 comments · Fixed by #1137

Comments

@wbamberg
Copy link
Collaborator

This came up in mdn/interactive-examples#1377.

If the output of the example is too long to fit the editor's div#console element, then the entire editor iframe gets a scrollbar.

Perhaps a simple fix would just be to change this: https://github.com/mdn/bob/blob/master/editor/css/editable-js.css#L27 to:

    white-space: pre-wrap;

?

@caugner
Copy link
Contributor

caugner commented May 3, 2022

@wbamberg I looked at the issue you're referencing, but it doesn't mention any URL where the problem appears.

Would you have an example page where this occurs, by any chance?

@wbamberg
Copy link
Collaborator Author

wbamberg commented May 3, 2022

The problem is mentioned at mdn/interactive-examples#1377 (review) as an issue for the example added in that PR, but we fixed it in content in that case, so it doesn't appear there.

The original problem was visible any time the console output overflowed the console.

It seems like we still have a version of it. Try https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat - we get 2 horizontal scrollbars, one for the entire editor and one for the console.

We should have 0 horizontal scrollbars, and the console should wrap the output (just like the console in the browser devtools).

@caugner
Copy link
Contributor

caugner commented May 3, 2022

To remove the horizontal scrollbar, we can indeed change white-space: pre to white-space: pre-wrap here:

.output code {
width: 100%;
height: 100px;
white-space: pre;

(And probably also here:)

.console code {
display: block;
width: 100%;
height: 100px;
white-space: pre;

To remove the vertical scrollbar in this specific example, we could reduce it to 13 repetitions.

Before

image

After

image

@wbamberg
Copy link
Collaborator Author

wbamberg commented May 3, 2022

To remove the vertical scrollbar in this specific example, we could reduce it to 13 repetitions.

Ouch, I hadn't seen that vertical scrollbar. But I don't think this is a content problem or should be fixed in content. If the content overflows a particular pane, it's fine for that pane to have a scrollbar, but the editor as a whole should never have scrollbars.

(I mean, there should be a kind of UI fiction that the editor is not in an iframe, but is part of the page.)

But actually, isn't the vertical scrollbar appearing because of the horizontal scrollbar? (because the h. scrollbar adds height, overflowing the iframe)? So if we fix the first, the second is fixed for us?

Screen Shot 2022-05-03 at 11 04 02 AM

@caugner
Copy link
Contributor

caugner commented Jun 9, 2023

(I mean, there should be a kind of UI fiction that the editor is not in an iframe, but is part of the page.)

@wbamberg I missed this last year, but FWIW the editor will most likely always be in an iframe for security reasons, to limit what scripts inside the editors have access to.

@wbamberg
Copy link
Collaborator Author

I understand that - that's why I said fiction.

There was an effort to un-iframify them a few years back, but it never went anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

2 participants