Skip to content

Commit

Permalink
fix(comp:textarea): fix line-height to ensure height calculation (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
sallerli1 authored and danranVm committed Oct 21, 2022
1 parent 7940bc5 commit 2d4ffa4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

exports[`Textarea > render work 1`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: vertical;\\"></textarea><!----></span>"`;
exports[`Textarea > resize and autoRows work 1`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: none; height: 0px; overflow: hidden;\\"></textarea><!----></span>"`;
exports[`Textarea > resize and autoRows work 1`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: none; line-height: -4px; height: 0px; overflow: hidden;\\"></textarea><!----></span>"`;
exports[`Textarea > resize and autoRows work 2`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: none; height: 0px; overflow: hidden;\\"></textarea><!----></span>"`;
exports[`Textarea > resize and autoRows work 2`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: none; line-height: -4px; height: 0px; overflow: hidden;\\"></textarea><!----></span>"`;
exports[`Textarea > resize and autoRows work 3`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: none; height: 0px; overflow: hidden; max-height: -4px;\\"></textarea><!----></span>"`;
exports[`Textarea > resize and autoRows work 3`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: none; line-height: -4px; height: 0px; overflow: hidden; max-height: -4px;\\"></textarea><!----></span>"`;
exports[`Textarea > resize and autoRows work 4`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: none; height: 0px; overflow: hidden; max-height: -4px;\\"></textarea><!----></span>"`;
exports[`Textarea > resize and autoRows work 4`] = `"<span class=\\"ix-textarea ix-textarea-md\\" data-count=\\"\\"><textarea class=\\"ix-textarea-inner\\" style=\\"resize: none; line-height: -4px; height: 0px; overflow: hidden; max-height: -4px;\\"></textarea><!----></span>"`;
2 changes: 2 additions & 0 deletions packages/components/textarea/src/composables/useAutoRows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ export function useAutoRows(
return
}

textarea.style.lineHeight = `${cachedLineHeight.value}px`

// Use the scrollHeight to know how large the textarea *would* be if fit its entire value.
const height = Math.max(getTextareaScrollHeight(), getTextareaPlaceholderHeight()!)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ function calcTextareaLineHeight(textarea: HTMLTextAreaElement | undefined): numb

return lineHeight
},
true,
false,
)
}

0 comments on commit 2d4ffa4

Please sign in to comment.