[fix] input cursor auto moving to the end
This commit is contained in:
@@ -3,10 +3,16 @@ import { Plus, SettingConfig, Switch } from "@icon-park/react"
|
||||
import { useSnapshot } from "valtio"
|
||||
import { Card, CardBody, CardHeader, CardIcon, CardTool } from "../window/Card"
|
||||
import { ToolButton } from "../window/ToolButton"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
const LaunchOption = () => {
|
||||
void toolStore.start()
|
||||
const { launchOptions, launchIndex } = useSnapshot(toolStore.state)
|
||||
const [launchOpt, setLaunchOpt] = useState(launchOptions[launchIndex] || "")
|
||||
|
||||
useEffect(() => {
|
||||
setLaunchOpt(launchOptions[launchIndex] || "")
|
||||
}, [launchIndex, launchOptions])
|
||||
|
||||
return (
|
||||
<Card>
|
||||
@@ -17,7 +23,7 @@ const LaunchOption = () => {
|
||||
<CardTool>
|
||||
{launchOptions.map((option, index) => (
|
||||
<ToolButton key={index} onClick={() => setLaunchIndex(index)}>
|
||||
{index+1}
|
||||
{index + 1}
|
||||
</ToolButton>
|
||||
))}
|
||||
<ToolButton onClick={() => addLaunchOption("")}>
|
||||
@@ -33,8 +39,12 @@ const LaunchOption = () => {
|
||||
<CardBody>
|
||||
<textarea
|
||||
placeholder="请输入启动选项"
|
||||
value={launchOptions[launchIndex] || ""}
|
||||
onChange={(e) => launchIndex !== -1 && setLaunchOption(e.target.value, launchIndex)}
|
||||
value={launchOpt}
|
||||
onChange={(e) => {
|
||||
if (launchIndex < 0 || launchIndex > 10) return
|
||||
setLaunchOpt(e.target.value)
|
||||
setLaunchOption(e.target.value, launchIndex)
|
||||
}}
|
||||
className="w-full font-mono text-base bg-transparent outline-none resize-none min-h-20"
|
||||
/>
|
||||
</CardBody>
|
||||
|
||||
Reference in New Issue
Block a user