JedWatson / react-input-autosize

Auto-resizing input field for React
https://jedwatson.github.io/react-input-autosize
MIT License
769 stars 178 forks source link

15 pixel different in width between Firefox and Chrome #135

Open amdrew opened 6 years ago

amdrew commented 6 years ago

I did search so I apologize if it's already been discussed.

There seems to be a 15px difference in width between Firefox and Chrome (probably Safari as well).

I.e the examples page (http://jedwatson.github.io/react-input-autosize/):

Chrome: Width of bottom input is 78 pixels

screen shot 2018-03-12 at 7 22 55 pm

Firefox: Width is 93 pixels

screen shot 2018-03-12 at 7 23 11 pm

I'm seeing the same 15 px difference in my project.

dliu120 commented 6 years ago

+1

This PR fixes the issue. I am currently overriding the sizer style(s) with css:

div[style] {
    overflow: hidden !important;
}
danielrob commented 6 years ago

@dliu120 this raises the input above the line for me in Firefox 60.0.2 on OSX (sandbox). My current very sad bit of browser detection workaround is:

const WrapHackAutosizeInput = styled.span`
  div[style] {
    margin-right: ${() => window.navigator.userAgent.includes('Firefox') ? '-17px' : '-2px'};
  }
`
iJoyCode commented 6 years ago

Same problem, fix pls

wtesler commented 6 years ago

Same

keul commented 5 years ago

The most annoying behavior I have is when the field is empty, where I have an input as 17 pixel width.

On a react-select based project I have (that internally use this library) emtpy selects (on the left) fills more vertical space because the input goes on a second line.

Schermata 2019-10-24 alle 13 39 51

ozluy commented 4 years ago

I just created a new NPM module please check it out:

https://github.com/ozluy/calculate-text-width image