Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line break titles #5471

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions ui/v2.5/src/components/Scenes/SceneDetails/SceneEditPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState, useMemo } from "react";
import React, { useEffect, useState, useMemo, useRef } from "react";
import { FormattedMessage, useIntl } from "react-intl";
import { Button, Form, Col, Row, ButtonGroup } from "react-bootstrap";
import Mousetrap from "mousetrap";
Expand Down Expand Up @@ -64,6 +64,7 @@ export const SceneEditPanel: React.FC<IProps> = ({
}) => {
const intl = useIntl();
const Toast = useToast();
const titleInputRef = useRef<HTMLInputElement>(null);

const [galleries, setGalleries] = useState<Gallery[]>([]);
const [performers, setPerformers] = useState<Performer[]>([]);
Expand Down Expand Up @@ -674,6 +675,42 @@ export const SceneEditPanel: React.FC<IProps> = ({
return renderInputField("details", "textarea", "details", props);
}

function renderTitleField() {
const displayValue = formik.values.title.replace(/\n/g, " ");

return (
<Form.Control
ref={titleInputRef}
className="text-input"
type="text"
value={displayValue}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
formik.setFieldValue("title", e.target.value);
}}
onKeyDown={(event: React.KeyboardEvent<HTMLInputElement>) => {
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);
formik.setFieldValue("title", newTitle);

setTimeout(() => {
if (titleInputRef.current) {
titleInputRef.current.setSelectionRange(
cursorPosition + 1,
cursorPosition + 1
);
}
}, 0);
}
}}
/>
);
}

return (
<div id="scene-edit-details">
<Prompt
Expand Down Expand Up @@ -730,7 +767,11 @@ export const SceneEditPanel: React.FC<IProps> = ({
</Row>
<Row className="form-container px-3">
<Col lg={7} xl={12}>
{renderInputField("title")}
{renderField(
"title",
intl.formatMessage({ id: "title" }),
renderTitleField()
)}
{renderInputField("code", "text", "scene_code")}

{renderURLListField("urls", onScrapeSceneURL, urlScrapable)}
Expand Down
6 changes: 6 additions & 0 deletions ui/v2.5/src/components/Scenes/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
padding: 0.5rem 1rem 0 1rem;
}

.text-input {
overflow: hidden;
text-overflow: ellipsis;
white-space: normal;
}

.performer-tag-container,
.group-tag-container {
display: inline-block;
Expand Down
Loading