mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-06-28 22:52:03 +08:00
feat: add option to disable focus to input box after answering (#317)
This commit is contained in:
@@ -117,5 +117,6 @@
|
||||
"Display selection tools next to input box to avoid blocking": "Display selection tools next to input box to avoid blocking",
|
||||
"Close All Chats In This Page": "Close All Chats In This Page",
|
||||
"When Icon Clicked": "When Icon Clicked",
|
||||
"Open Settings": "Open Settings"
|
||||
"Open Settings": "Open Settings",
|
||||
"Focus to input box after answering": "Focus to input box after answering"
|
||||
}
|
||||
|
||||
@@ -117,5 +117,6 @@
|
||||
"Display selection tools next to input box to avoid blocking": "将选择浮动工具显示在输入框旁边以避免遮挡",
|
||||
"Close All Chats In This Page": "关闭本页所有聊天",
|
||||
"When Icon Clicked": "当图标被点击时",
|
||||
"Open Settings": "打开设置"
|
||||
"Open Settings": "打开设置",
|
||||
"Focus to input box after answering": "回答结束后自动聚焦到输入框"
|
||||
}
|
||||
|
||||
@@ -117,5 +117,6 @@
|
||||
"Display selection tools next to input box to avoid blocking": "將選擇浮動工具顯示在輸入框旁邊以避免遮擋",
|
||||
"Close All Chats In This Page": "關閉本頁所有對話",
|
||||
"When Icon Clicked": "當圖示被點擊時",
|
||||
"Open Settings": "開啟設定"
|
||||
"Open Settings": "開啟設定",
|
||||
"Focus to input box after answering": "回答結束後自動聚焦到輸入框"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useRef, useState } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { updateRefHeight } from '../../utils'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { getUserConfig } from '../../config/index.mjs'
|
||||
|
||||
export function InputBox({ onSubmit, enabled, port, reverseResizeDir }) {
|
||||
const { t } = useTranslation()
|
||||
@@ -13,6 +14,8 @@ export function InputBox({ onSubmit, enabled, port, reverseResizeDir }) {
|
||||
const virtualInputRef = reverseResizeDir ? reverseDivRef : inputRef
|
||||
|
||||
useEffect(() => {
|
||||
inputRef.current.focus()
|
||||
|
||||
const onResizeY = () => {
|
||||
if (virtualInputRef.current.h !== virtualInputRef.current.offsetHeight) {
|
||||
virtualInputRef.current.h = virtualInputRef.current.offsetHeight
|
||||
@@ -37,7 +40,10 @@ export function InputBox({ onSubmit, enabled, port, reverseResizeDir }) {
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (enabled) inputRef.current.focus()
|
||||
if (enabled)
|
||||
getUserConfig().then((config) => {
|
||||
if (config.focusAfterAnswer) inputRef.current.focus()
|
||||
})
|
||||
}, [enabled])
|
||||
|
||||
const handleKeyDownOrClick = (e) => {
|
||||
|
||||
@@ -96,6 +96,7 @@ export const defaultConfig = {
|
||||
autoRegenAfterSwitchModel: false,
|
||||
selectionToolsNextToInputBox: false,
|
||||
alwaysPinWindow: false,
|
||||
focusAfterAnswer: true,
|
||||
|
||||
apiKey: '', // openai ApiKey
|
||||
|
||||
|
||||
@@ -360,6 +360,17 @@ export function GeneralPart({ config, updateConfig }) {
|
||||
/>
|
||||
{t('Always pin the floating window')}
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={config.focusAfterAnswer}
|
||||
onChange={(e) => {
|
||||
const checked = e.target.checked
|
||||
updateConfig({ focusAfterAnswer: checked })
|
||||
}}
|
||||
/>
|
||||
{t('Focus to input box after answering')}
|
||||
</label>
|
||||
<br />
|
||||
</>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user