fixed start page and scroll in modal window

This commit is contained in:
SlimusMinus
2026-08-18 01:06:50 +03:00
parent 272a0bd050
commit 10fea3cf2a
17 changed files with 142 additions and 68 deletions

View File

@@ -11,25 +11,18 @@ import DateCalendarPopup from "../components/DateCalendarPopup";
import Toast from "../components/Toast";
import {useTranslation} from 'react-i18next';
export default function PostOnFeed({ ad, liked, onLike, onEdit, onDelete, onMarkFound, isOwner, onImageClick, onAuthRequired }) {
export default function PostOnFeed({ ad, liked, likeCountAdj, onLike, onEdit, onDelete, onMarkFound, isOwner, onImageClick, onAuthRequired }) {
const { t } = useTranslation();
const [showCalendar, setShowCalendar] = useState(false);
const [titleExpanded, setTitleExpanded] = useState(false);
const [descExpanded, setDescExpanded] = useState(false);
const [titleTruncated, setTitleTruncated] = useState(false);
const [descTruncated, setDescTruncated] = useState(false);
const dateAnchorRef = useRef(null);
const titleRef = useRef(null);
const descRef = useRef(null);
const { isAuthenticated } = useAuthContext();
const { contactSeller, error: contactError, clearError } = useContactSeller(ad);
// Определяем, обрезан ли title/description (тремя точками), и реагируем на ресайз
useEffect(() => {
const check = () => {
if (!titleExpanded && titleRef.current) {
setTitleTruncated(titleRef.current.scrollWidth > titleRef.current.clientWidth + 1);
}
if (!descExpanded && descRef.current) {
setDescTruncated(descRef.current.scrollHeight > descRef.current.clientHeight + 1);
}
@@ -37,7 +30,7 @@ export default function PostOnFeed({ ad, liked, onLike, onEdit, onDelete, onMark
check();
window.addEventListener("resize", check);
return () => window.removeEventListener("resize", check);
}, [titleExpanded, descExpanded]);
}, [descExpanded]);
const handleContact = (e) => {
e.stopPropagation();
@@ -68,9 +61,7 @@ export default function PostOnFeed({ ad, liked, onLike, onEdit, onDelete, onMark
<div className="f-card-head">
<div className="f-card-author">
<div
ref={titleRef}
className={`f-card-author-name${titleTruncated ? " f-truncatable" : ""}${titleExpanded ? " f-expanded" : ""}`}
onClick={titleTruncated ? () => setTitleExpanded(v => !v) : undefined}
className="f-card-author-name"
>
{ad.title}
</div>
@@ -100,7 +91,7 @@ export default function PostOnFeed({ ad, liked, onLike, onEdit, onDelete, onMark
}}>
<HeartIcon filled={liked}/>
</button>
<span className="f-card-like-count">{ad.likeCount || 0}</span>
<span className="f-card-like-count">{(ad.likeCount || 0) + likeCountAdj}</span>
</div>
<div className="f-card-actions-right">
{onEdit && isOwner && !isClosed && (