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

Short lines in previously hidden terminal when terminal have position: fixed #466

Closed
paulsmirnov opened this issue Feb 12, 2019 · 5 comments
Labels
Bug resolved if issue is resolved, it will be open until merge with master

Comments

@paulsmirnov
Copy link

Expected behavior

I expect to be able to attach the terminal plugin to a div even if the div is currently hidden. When I show the div later ("on-demand" console) it should display text correctly.

Actual behavior

When I show the div later, the text in the terminal is split into lines, one character per line. When I enter new text it is being split too.

Steps to reproduce

See this code pen: https://codepen.io/paulsmirnov/pen/NozwLQ

Browser and OS

Windows 10 + Chrome/Firefox/Edge

Hints

  • After playing with CodePen for a while I think it works with jQuery 3.1.1 but fails to work with 3.3.1 (the latest).
  • Also, the jquery.terminal 1.2 works ok, 1.3-1.4 throws an exception, 1.5+ fails to display text correctly.
@jcubic
Copy link
Owner

jcubic commented Feb 12, 2019

The code is handling this by using Intersection and Mutation observers. One is used if you create terminal on div that's not yet in DOM and the second when div is not visible, will look into that.

Quick test of the pen give this:

$.terminal.active().cols()
-Infinity

it probably get the width of the terminal which is 0, when it's not visible.

Right now you can fix this by using:

$('#term').show().terminal().resize();

@jcubic jcubic added the Bug label Feb 12, 2019
@jcubic
Copy link
Owner

jcubic commented Feb 12, 2019

The issue is position: fixed that already give trouble in #324

@jcubic jcubic changed the title Short lines in previously hidden terminal Short lines in previously hidden terminal when terminal have position: fixed Feb 12, 2019
@jcubic
Copy link
Owner

jcubic commented Feb 12, 2019

The problem was that Intersection Observer don't work if element have position: fixed
ref: Intersection observer does not work with target with position: fixed

and Chrome bug with WontFix status Issue 653240: Intersection Observer not firing when root is body and element is position: fixed

@jcubic
Copy link
Owner

jcubic commented Feb 12, 2019

The fix will be in version 2.2.0 you can try it from CDNJS url

https://cdn.jsdelivr.net/gh/jcubic/jquery.terminal@devel/js/jquery.terminal.min.js

@paulsmirnov
Copy link
Author

Great, thanks! .resize() also did the trick.

paulsmirnov added a commit to epam/miew that referenced this issue Feb 13, 2019
@jcubic jcubic added the resolved if issue is resolved, it will be open until merge with master label Feb 13, 2019
paulsmirnov pushed a commit to epam/miew that referenced this issue Feb 13, 2019
* chore(package): update jquery.terminal to version 1.17.0
* chore(package): update jquery.terminal to version 2.0.2
* update jquery.terminal to version 2.1.2
* Force terminal resize (jcubic/jquery.terminal#466)

Closes #58
@jcubic jcubic closed this as completed in 82edb41 Feb 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug resolved if issue is resolved, it will be open until merge with master
Projects
None yet
Development

No branches or pull requests

2 participants