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

Auto fit addon doesn't work when parent element uses border-box #1283

Open
cancan101 opened this issue Feb 12, 2018 · 4 comments
Open

Auto fit addon doesn't work when parent element uses border-box #1283

cancan101 opened this issue Feb 12, 2018 · 4 comments

Comments

@cancan101
Copy link

cancan101 commented Feb 12, 2018

The calculations for height and width of the parent in the auto fit plugin are incorrect when the parent element uses box-sizing: border-box. This is because the computed height includes the padding but the content does not.

The right implementation might be to get the client height of the parent element using gBCR and then subtract the parent padding.

/CC @taion

@mofux
Copy link
Contributor

mofux commented Feb 13, 2018

@cancan101 Are you sure it's failing on box-sizing: border-box? I would have thought that it might fail with box-sizing: content-box 🤔

@taion
Copy link

taion commented Feb 13, 2018

It's for border-box. Suppose you have an element with height: 100px and padding: 20px 0 0 0.

If we have box-sizing: content-box, then the computed height style is 100, which is correct.

If we have box-sizing: border-box, then the computed height style is still 100, but the actual content height is 80.

Instead it needs to be client height minus padding to account for this (I think, unless there's a more direct way to read content height).

@Tyriar Tyriar added type/bug Something is misbehaving addon labels Jun 8, 2018
@Tyriar Tyriar changed the title Auto fit addond Has Issues when Parent Element uses border-box Auto fit addon doesn't work when parent element uses border-box Oct 7, 2019
@Tyriar
Copy link
Member

Tyriar commented Oct 7, 2019

Open to PRs, you can repro this in the demo by adding box-sizing: border-box to #terminal-container. The fix will probably need to check for border-box on the container, if it's there include border and padding style values in the calculations.

@Consolatis
Copy link

This bug just hit me again but this time I decided to actually investigate the reason and found this issue.
Setting box-sizing: content-box for #term-container indeed fixed the issue for me (bootstrap set * to border-box).

This issue may be fixed / worked around with using one of two different approaches:

  • either the proper way as concluded by @Tyriar
  • or by setting box-sizing: content-box on this._terminal.element.parentElement while loading the addon

At the very least it should be documented here https://xtermjs.org/docs/api/addons/fit/

RobertBlackhart added a commit to RobertBlackhart/ViperIDE that referenced this issue Aug 7, 2024
This appears to be due to the interplay of the padding on
the #xterm element and the box-sizing of the #terminal-container
element being set to border-box. This issue in the xterm.js repository
talks about the same thing: xtermjs/xterm.js#1283

The workaround mentioned in the issue appears to solve the problem here.
That is, set the box-sizing on the #terminal-container to be content-box.
RobertBlackhart added a commit to RobertBlackhart/ViperIDE that referenced this issue Aug 7, 2024
This appears to be due to the interplay of the padding on
the #xterm element and the box-sizing of the #terminal-container
element being set to border-box. This issue in the xterm.js repository
talks about the same thing: xtermjs/xterm.js#1283

The workaround mentioned in the issue appears to solve the problem here.
That is, set the box-sizing on the #terminal-container to be content-box.
RobertBlackhart added a commit to RobertBlackhart/ViperIDE that referenced this issue Aug 7, 2024
This appears to be due to the interplay of the padding on
the #xterm element and the box-sizing of the #terminal-container
element being set to border-box. This issue in the xterm.js repository
talks about the same thing: xtermjs/xterm.js#1283

The workaround mentioned in the issue appears to solve the problem here.
That is, set the box-sizing on the #terminal-container to be content-box.
vshymanskyy pushed a commit to vshymanskyy/ViperIDE that referenced this issue Aug 8, 2024
This appears to be due to the interplay of the padding on
the #xterm element and the box-sizing of the #terminal-container
element being set to border-box. This issue in the xterm.js repository
talks about the same thing: xtermjs/xterm.js#1283

The workaround mentioned in the issue appears to solve the problem here.
That is, set the box-sizing on the #terminal-container to be content-box.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants