mirror of
https://github.com/stashapp/stash.git
synced 2025-12-06 08:26:00 +01:00
prettier / validate / pressing enter in input field allows line breaks
couldn't figure out how to visually represent the line breaks in edit field (currently uses space character for new line) line breaks are lost if any other change made to edit field. otherwise, works alright
This commit is contained in:
parent
615fe18593
commit
097d9f7d73
2 changed files with 15 additions and 15 deletions
|
|
@ -64,8 +64,7 @@ export const SceneEditPanel: React.FC<IProps> = ({
|
|||
}) => {
|
||||
const intl = useIntl();
|
||||
const Toast = useToast();
|
||||
const titleInputRef = useRef<HTMLInputElement>(null); // Move ref hook to top
|
||||
|
||||
const titleInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const [galleries, setGalleries] = useState<Gallery[]>([]);
|
||||
const [performers, setPerformers] = useState<Performer[]>([]);
|
||||
|
|
@ -677,9 +676,8 @@ export const SceneEditPanel: React.FC<IProps> = ({
|
|||
}
|
||||
|
||||
function renderTitleField() {
|
||||
const displayValue = formik.values.title.replace(/\n/g, ' ');
|
||||
console.log("Rendering with value:", displayValue);
|
||||
|
||||
const displayValue = formik.values.title.replace(/\n/g, " ");
|
||||
|
||||
return (
|
||||
<Form.Control
|
||||
ref={titleInputRef}
|
||||
|
|
@ -693,16 +691,18 @@ export const SceneEditPanel: React.FC<IProps> = ({
|
|||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
const cursorPosition = event.currentTarget.selectionStart ?? 0;
|
||||
const newTitle = formik.values.title.substring(0, cursorPosition) +
|
||||
'\n' +
|
||||
formik.values.title.substring(cursorPosition);
|
||||
console.log("New title:", newTitle);
|
||||
const newTitle =
|
||||
formik.values.title.substring(0, cursorPosition) +
|
||||
"\n" +
|
||||
formik.values.title.substring(cursorPosition);
|
||||
formik.setFieldValue("title", newTitle);
|
||||
|
||||
// Safely restore cursor position
|
||||
|
||||
setTimeout(() => {
|
||||
if (titleInputRef.current) {
|
||||
titleInputRef.current.setSelectionRange(cursorPosition + 1, cursorPosition + 1);
|
||||
titleInputRef.current.setSelectionRange(
|
||||
cursorPosition + 1,
|
||||
cursorPosition + 1
|
||||
);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@
|
|||
}
|
||||
|
||||
.text-input {
|
||||
white-space: normal !important;
|
||||
overflow: hidden !important;
|
||||
text-overflow: ellipsis !important;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.performer-tag-container,
|
||||
|
|
|
|||
Loading…
Reference in a new issue