Skip to content

Commit

Permalink
fix(QIput): do not change overflow on autogrow textarea because it br…
Browse files Browse the repository at this point in the history
…eaks undo and does not compute size as expected #14344, #14263, #13196 (#14397)
  • Loading branch information
pdanpdan committed Sep 15, 2022
1 parent 3438b4e commit 24ffd09
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions ui/src/components/input/QInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,24 @@ export default Vue.extend({

// textarea only
__adjustHeight () {
const inp = this.$refs.input
if (inp !== void 0) {
const parentStyle = inp.parentNode.style
const { overflow } = inp.style

// reset height of textarea to a small size to detect the real height
// but keep the total control size the same
parentStyle.marginBottom = (inp.scrollHeight - 1) + 'px'
inp.style.height = '1px'
inp.style.overflow = 'hidden'

inp.style.height = inp.scrollHeight + 'px'
inp.style.overflow = overflow
parentStyle.marginBottom = ''
}
requestAnimationFrame(() => {
const inp = this.$refs.input
if (inp !== void 0) {
const parentStyle = inp.parentNode.style
const { overflow } = inp.style

// reset height of textarea to a small size to detect the real height
// but keep the total control size the same
// Firefox rulez #14263, #14344
this.$q.platform.is.firefox !== true && (inp.style.overflow = 'hidden')
inp.style.height = '1px'
parentStyle.marginBottom = (inp.scrollHeight - 1) + 'px'

inp.style.height = inp.scrollHeight + 'px'
inp.style.overflow = overflow
parentStyle.marginBottom = ''
}
})
},

__onChange (e) {
Expand Down

0 comments on commit 24ffd09

Please sign in to comment.