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

<input>'s don't resize on IE #9

Closed
petetnt opened this issue Jul 30, 2015 · 4 comments
Closed

<input>'s don't resize on IE #9

petetnt opened this issue Jul 30, 2015 · 4 comments

Comments

@petetnt
Copy link

petetnt commented Jul 30, 2015

Yay, yet another IE bug (tested with Microsoft Edge, IE11, IE11 Mobile, most likely affects all of them).

When calculating the placeholder width on stretchy.js#L76

var width = Math.max(element.scrollLeft + offset, element.scrollWidth - element.clientWidth);

the problem is that element.scrollLeft never actually updates on <input>-elements on IE, which results to the inputs being offset wide forever:

image

There's an workaround for Safari above that line, but like I said, I think the value of scrollLeft stays 0 forever no matter what so I think any workarounds using scrollLeft are out of the picture for an IE fix.

The popular[1] workaround[2] is to use <textarea>s with single rows forced instead, but that doesn't really apply to Scretchy as the whole point is to have a variety of autosizing form elements instead of just going "screw it, just use <textarea> for everything" 🔨

@petetnt petetnt changed the title <input>'s with placeholders don't resize on IE <input>'s don't resize on IE Jul 31, 2015
@LeaVerou
Copy link
Owner

This is a known issue and doesn't only affect inputs with placeholders. Check the Browser Support Notes.
@gregwhitworth from MS is working on a polyfill to address this, and he's also working on getting it fixed in Edge, all because of Stretchy :)

petetnt added a commit to petetnt/stretchy that referenced this issue Jul 31, 2015
@petetnt
Copy link
Author

petetnt commented Jul 31, 2015

@LeaVerou yeah the placeholder mention was an oversight from me, so I fixed the title earlier.

Anyway, oh dang. I just pushed a commit on my fork of scretchy that fixes this for IE9-11 + Edge. I am not super happy with it but it does work.

Can't believe I missed that mention about the polyfill, I am sure that I am going blind these days 🍔

petetnt added a commit to petetnt/stretchy that referenced this issue Jul 31, 2015
@Yaffle
Copy link

Yaffle commented Mar 3, 2016

element.scrollWidth - element.clientWidth ( https://github.com/LeaVerou/stretchy/blob/gh-pages/stretchy.js#L76 )
@LeaVerou , Could you please explain what does it mean?
Probably, element.scrollWidth + (offset - element.clientWidth) should be used, offset - element.clientWidth gives borderLeftWidth + borderRightWidth

@Yaffle
Copy link

Yaffle commented Mar 3, 2016

  1. In Webkit-based browsers (Chrome, Safari) input.scrollLeft is incorrect when zoom was used.
    But the expression element.scrollWidth + (offset - element.clientWidth) looks correct for me in Chrome, while Math.max(input.scrollLeft, ...) is not, because when the page zoom < 100% first argument for Math.max is larger.
  2. AFAIK, both input.scrollWidth and input.scrollLeft are incorrect in Opera 12, IE > 8 (including Edge)

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

No branches or pull requests

3 participants