-
Notifications
You must be signed in to change notification settings - Fork 3.4k
fix(textarea): scrolling, text selection, reduced DOM manipulation. #7553
Conversation
// This is necessary, because browsers fire a `mouseup` right after the element | ||
// has been focused. In some browsers (Firefox in particular) this can clear the | ||
// selection. There are examples of the problem in issue #7487. | ||
element.on('mouseup', preventMouseUp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it make more sense to keep the mouseup
event registered and just change a state in the directive?. Adding / Removing events is more harmful, than just an empty event handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, we can keep track of it in the mouseup
, I'll give it a try.
That would mean adding another handler for blur
, though.
a79d1e8
to
0ba5bae
Compare
element[0].select(); | ||
// Use HTMLInputElement#select to fix firefox select issues. | ||
// The debounce is here for Edge's sake, otherwise the selection doesn't work. | ||
preventMouseUp = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if I focus the element using keyboard interaction? The mouseup
event can't be triggered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, it actually prevents the first click afterwards. Not sure how we could distinguish between the two though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is the mouseup
event usually called? Before the 1ms delay? I've got no time, to test that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have it running atm either, but from what I remember it's afterwards. I'll take a closer look at it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good now with resetting it from inside the $timeout
. Also had time to test it out in most browsers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's exactly what I've thought about. Great 👍
* Fixes `mdSelectOnFocus` not working in Edge and being unreliable in Firefox. * Fixes `textarea` not being scrollable once it is past it's minimum number of rows. * Fixes `textarea` not being scrollable if `mdNoAutogrow` is specified. * Tries to reduce the number of event listeners and the amount of DOM manipulation when resizing the `textarea`. Closes angular#7487.
0ba5bae
to
526dbdb
Compare
onChangeTextarea(); | ||
return value; | ||
} | ||
var minRows = attr.hasOwnProperty('rows') ? parseInt(attr.rows) : NaN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How can I now let the textarea grow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't specify the rows. It works in the same way as before, I just made it a one-liner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, just rechecked with the latest version. Everything works fine 👍
* Fixes `mdSelectOnFocus` not working in Edge and being unreliable in Firefox. * Fixes `textarea` not being scrollable once it is past it's minimum number of rows. * Fixes `textarea` not being scrollable if `mdNoAutogrow` is specified. * Tries to reduce the number of event listeners and the amount of DOM manipulation when resizing the `textarea`. Fixes #7487. Closes #7553
Hope that PR solves that issue too: |
mdSelectOnFocus
not working in Edge and being unreliable in Firefox.textarea
not being scrollable once it is past it's minimum number of rows.textarea
not being scrollable ifmdNoAutogrow
is specified.textarea
.Closes #7487.