mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 08:13:43 +08:00 
			
		
		
		
	fix: row count logic
This commit is contained in:
		@@ -158,15 +158,15 @@ export function autoGrowTextArea(dom: HTMLTextAreaElement) {
 | 
			
		||||
 | 
			
		||||
  const width = getDomContentWidth(dom);
 | 
			
		||||
  measureDom.style.width = width + "px";
 | 
			
		||||
  measureDom.innerText = dom.value.trim().length > 0 ? dom.value : "1";
 | 
			
		||||
 | 
			
		||||
  const emptyLineWrap = Math.max(0, dom.value.split("\n\n").length - 1);
 | 
			
		||||
  measureDom.innerText = dom.value !== "" ? dom.value : "1";
 | 
			
		||||
  const endWithEmptyLine = dom.value.endsWith("\n");
 | 
			
		||||
  const height = parseFloat(window.getComputedStyle(measureDom).height);
 | 
			
		||||
  const singleLineHeight = parseFloat(
 | 
			
		||||
    window.getComputedStyle(singleLineDom).height,
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  const rows = Math.round(height / singleLineHeight) + emptyLineWrap;
 | 
			
		||||
  const rows =
 | 
			
		||||
    Math.round(height / singleLineHeight) + (endWithEmptyLine ? 1 : 0);
 | 
			
		||||
 | 
			
		||||
  return rows;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user