perf: use native composer sizing where supported (#6760)
Use native CSS field-sizing for composer auto-grow where supported, keeping the JS path as fallback. Includes a fallback-parity fix so an empty composer holds its resting height instead of measuring the placeholder. Co-authored-by: starship-s <starship-s@users.noreply.github.com>
This commit is contained in:
1 parent
8fa1244279
commit
2afcdf2676
3 files changed
+109
-1
No files matched your search
@@ -7236,7 +7236,28 @@ function autoResize(){
|
||||
}
|
||||
const el=$('msg');
|
||||
const _nextValue=String(el.value||'');
|
||||
if(typeof CSS!=='undefined'&&typeof CSS.supports==='function'&&CSS.supports('field-sizing','content')){
|
||||
if(el.style.height) el.style.height='';
|
||||
_composerLastResizeValue=_nextValue;
|
||||
updateSendBtn();
|
||||
return;
|
||||
}
|
||||
const _isAppendOnly=_nextValue.length>_composerLastResizeValue.length&&_nextValue.startsWith(_composerLastResizeValue);
|
||||
// An EMPTY composer has no content to measure, so clear any inline height and
|
||||
// let the CSS `min-height` define the resting size. Measuring instead would
|
||||
// read the PLACEHOLDER's scrollHeight — a long busy/compression hint wraps to
|
||||
// two or three lines and would grow the empty composer (71px for the English
|
||||
// busy hint, 97px for the French compression one) purely because of hint text.
|
||||
// That made the empty height history-dependent on this path: 44px on a fresh
|
||||
// send, but grown after any later resize while empty. The native
|
||||
// `field-sizing` path above always holds the resting height, so clearing here
|
||||
// keeps both paths on the same contract.
|
||||
if(!_nextValue){
|
||||
if(el.style.height) el.style.height='';
|
||||
_composerLastResizeValue=_nextValue;
|
||||
updateSendBtn();
|
||||
return;
|
||||
}
|
||||
const _fitsCurrentHeight=el.scrollHeight<=el.offsetHeight;
|
||||
// Only a direct append at the natural one-row height can skip the height
|
||||
// round trip. Replacements and an already-tall composer must remeasure so the
|
||||
|
||||
Reference in new issue
Block a user