mirror of
https://github.com/stashapp/stash.git
synced 2026-05-08 12:32:29 +02:00
Actually do what previous commit said
Add JavaScript Key Event Handling: Capture the Enter key press within the title input field to insert a newline character.
This commit is contained in:
parent
b4f9c5e510
commit
d9493d8385
2 changed files with 36 additions and 1 deletions
|
|
@ -674,6 +674,37 @@ export const SceneEditPanel: React.FC<IProps> = ({
|
|||
return renderInputField("details", "textarea", "details", props);
|
||||
}
|
||||
|
||||
const [titleInput, setTitleInput] = useState(scene.title ?? "");
|
||||
|
||||
const handleTitleKeyPress = (
|
||||
event: React.KeyboardEvent<HTMLInputElement>
|
||||
) => {
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
const newTitle = titleInput + "\n";
|
||||
setTitleInput(newTitle);
|
||||
formik.setFieldValue("title", newTitle);
|
||||
}
|
||||
};
|
||||
|
||||
function renderTitleField() {
|
||||
return (
|
||||
<Form.Control
|
||||
className="text-input"
|
||||
type="text"
|
||||
value={titleInput}
|
||||
onChange={(e) => {
|
||||
const newValue = e.target.value;
|
||||
setTitleInput(newValue);
|
||||
formik.setFieldValue("title", newValue);
|
||||
}}
|
||||
onKeyPress={handleTitleKeyPress}
|
||||
style={{ whiteSpace: "pre-wrap" }}
|
||||
isInvalid={!!formik.errors.title}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div id="scene-edit-details">
|
||||
<Prompt
|
||||
|
|
@ -730,7 +761,11 @@ export const SceneEditPanel: React.FC<IProps> = ({
|
|||
</Row>
|
||||
<Row className="form-container px-3">
|
||||
<Col lg={7} xl={12}>
|
||||
{renderInputField("title", "textarea")}
|
||||
{renderField(
|
||||
"title",
|
||||
intl.formatMessage({ id: "title" }),
|
||||
renderTitleField()
|
||||
)}
|
||||
{renderInputField("code", "text", "scene_code")}
|
||||
|
||||
{renderURLListField("urls", onScrapeSceneURL, urlScrapable)}
|
||||
|
|
|
|||
Loading…
Reference in a new issue