Skip to content

Commit

Permalink
🐛 fix: textarea の height が max-height を超えた時にのみ拡張ボタンが表示されるように条件を改善
Browse files Browse the repository at this point in the history
  • Loading branch information
reiroop committed Feb 3, 2025
1 parent bc316cb commit f61605b
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/components/Main/MainView/MessageInput/MessageInputTextArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,19 @@ const onBlur = () => {
emit('blur')
}
const textAreaAutoSizeMaxHeightShrunk = computed(() =>
isMobile.value ? 70 : 160
)

Check warning on line 148 in src/components/Main/MainView/MessageInput/MessageInputTextArea.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageInput/MessageInputTextArea.vue#L146-L148

Added lines #L146 - L148 were not covered by tests
const textAreaAutoSizeMaxHeight = computed(() => {
if (props.isMaxHeightNone) {
return 'none'
}
if (isMobile.value) {
return props.isInputTextAreaExpanded ? '140px' : '70px'
} else {
return props.isInputTextAreaExpanded ? '320px' : '160px'
}
return (
(props.isInputTextAreaExpanded
? textAreaAutoSizeMaxHeightShrunk.value * 2
: textAreaAutoSizeMaxHeightShrunk.value) + 'px'

Check warning on line 157 in src/components/Main/MainView/MessageInput/MessageInputTextArea.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageInput/MessageInputTextArea.vue#L150-L157

Added lines #L150 - L157 were not covered by tests
)
})

Check warning on line 159 in src/components/Main/MainView/MessageInput/MessageInputTextArea.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageInput/MessageInputTextArea.vue#L159

Added line #L159 was not covered by tests
const scollbarWidth = getScrollbarWidth()
Expand All @@ -168,24 +171,18 @@ const showIsInputTextAreaExpandedButton = defineModel<boolean>(
}
)

Check warning on line 172 in src/components/Main/MainView/MessageInput/MessageInputTextArea.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageInput/MessageInputTextArea.vue#L172

Added line #L172 was not covered by tests
const updateTextareaExpandButtonVisibility = () => {
if (textareaRef.value) {
const height = textareaRef.value.scrollHeight
if (isMobile.value) {
showIsInputTextAreaExpandedButton.value = height >= 70
} else {
showIsInputTextAreaExpandedButton.value = height >= 160
const updateShowIsInputTextareaExpandButtonVisibility = () => {
nextTick(() => {
if (textareaRef.value) {
showIsInputTextAreaExpandedButton.value =
textareaRef.value.scrollHeight > textAreaAutoSizeMaxHeightShrunk.value
}
}
})

Check warning on line 180 in src/components/Main/MainView/MessageInput/MessageInputTextArea.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageInput/MessageInputTextArea.vue#L174-L180

Added lines #L174 - L180 were not covered by tests
}
watch(
value,
() => {
nextTick(() => {
updateTextareaExpandButtonVisibility()
})
},
[() => textareaRef.value?.scrollHeight, value],
updateShowIsInputTextareaExpandButtonVisibility,
{ immediate: true }
)

Check warning on line 187 in src/components/Main/MainView/MessageInput/MessageInputTextArea.vue

View check run for this annotation

Codecov / codecov/patch

src/components/Main/MainView/MessageInput/MessageInputTextArea.vue#L183-L187

Added lines #L183 - L187 were not covered by tests
</script>
Expand Down

0 comments on commit f61605b

Please sign in to comment.