Skip to content

Commit 639d6e0

Browse files
author
Aqib Mirza
committed
fix: comment component
1 parent c3132a4 commit 639d6e0

File tree

1 file changed

+121
-122
lines changed

1 file changed

+121
-122
lines changed

client/packages/lowcoder/src/comps/comps/commentComp/commentComp.tsx

Lines changed: 121 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -214,138 +214,137 @@ const CommentCompBase = (
214214
}
215215
};
216216
return (
217-
<div
218-
style={{
217+
<div style={{
219218
margin: style.margin ?? "3px",
220219
padding: style.padding ?? "3px",
221220
width: widthCalculator(style.margin ?? "3px"),
222221
height: heightCalculator(style.margin ?? "3px"),
223222
background: style.background,
224-
overflow: "auto",
225-
overflowX: "hidden",
226223
borderRadius: style.radius,
227-
}}
228-
ref={divRef}
229-
>
230-
<List
231-
header={
232-
title !== "" ? (
233-
<div>
234-
{commentListData.length > 1
235-
? title
236-
.replaceAll("%d", commentListData.length.toString())
237-
.replace("comment", "comments")
238-
: title.replaceAll("%d", commentListData.length.toString())}
239-
</div>
240-
) : (
241-
""
242-
)
243-
}
244-
size="small"
224+
}}>
225+
<div
226+
style={{
227+
overflow: "auto",
228+
overflowX: "hidden",
229+
height: "100%",
230+
}}
231+
ref={divRef}
245232
>
246-
<VirtualList
247-
data={commentListData}
248-
////////////////////////////////////////////////////////////////
249-
// T_T , Frustrating, unable to obtain component height
250-
// height={height - (sendCommentAble ? 145 : 45) + (title === "" ? 40 : 0)}
251-
// ref={VirtualListRef}
252-
////////////////////////////////////////////////////////////////
253-
itemKey="createdAt"
233+
<List
234+
header={
235+
title !== "" ? (
236+
<div style={{position: 'sticky', top:0, background: style.background}}>
237+
{commentListData.length > 1
238+
? title
239+
.replaceAll("%d", commentListData.length.toString())
240+
.replace("comment", "comments")
241+
: title.replaceAll("%d", commentListData.length.toString())}
242+
</div>
243+
) : (
244+
""
245+
)
246+
}
247+
size="small"
254248
>
255-
{(item, index) => (
256-
<List.Item
257-
key={item?.createdAt}
258-
actions={
259-
deleteAble
260-
? [
261-
<CloseOutlined
262-
style={{ color: "#c32230" }}
263-
onClick={() => handleDelete(index)}
264-
/>,
265-
]
266-
: undefined
267-
}
268-
>
269-
<List.Item.Meta
270-
avatar={generateCommentAvatar(item)}
271-
title={
272-
<div onClick={() => props.onEvent("click")}>
273-
<a>{item?.user?.name}</a>
274-
<Tooltip
275-
title={
276-
dayjs(item?.createdAt).isValid()
277-
? dayjs(item?.createdAt).format("YYYY/M/D HH:mm:ss")
278-
: trans("comment.dateErr")
279-
}
280-
placement="bottom"
281-
>
282-
<span
283-
style={{
284-
paddingLeft: "5px",
285-
color: "#999",
286-
fontSize: "11px",
287-
}}
288-
>
289-
{dayjs(item?.createdAt).isValid()
290-
? dayjs(item?.createdAt).fromNow()
291-
: trans("comment.dateErr")}
292-
</span>
293-
</Tooltip>
294-
</div>
295-
}
296-
description={<span>{item?.value}</span>}
297-
/>
298-
</List.Item>
299-
)}
300-
</VirtualList>
301-
</List>
302-
{sendCommentAble ? (
303-
<>
304-
<Mentions
305-
style={{
306-
width: "98%",
307-
height: 50,
308-
margin: "0px 10px 0px 5px",
309-
// position: "fixed",
310-
// bottom: "50px",
311-
}}
312-
onSearch={onSearch}
313-
prefix={Object.keys(MentionListData)}
314-
onChange={onChange}
315-
onSelect={(option: any) => {
316-
dispatch(changeChildAction("mentionName", option?.value, false));
317-
props.onEvent("mention");
318-
}}
319-
value={context}
320-
rows={2}
321-
onPressEnter={onPressEnter}
322-
placeholder={placeholder}
249+
<VirtualList
250+
data={commentListData}
251+
////////////////////////////////////////////////////////////////
252+
// T_T , Frustrating, unable to obtain component height
253+
// height={height - (sendCommentAble ? 145 : 45) + (title === "" ? 40 : 0)}
254+
// ref={VirtualListRef}
255+
////////////////////////////////////////////////////////////////
256+
itemKey="createdAt"
323257
>
324-
{(MentionListData[prefix] || []).map(
325-
(value: string, index: number) => (
326-
<Mentions.Option key={index.toString()} value={value}>
327-
{value}
328-
</Mentions.Option>
329-
)
258+
{(item, index) => (
259+
<List.Item
260+
key={item?.createdAt}
261+
actions={
262+
deleteAble
263+
? [
264+
<CloseOutlined
265+
style={{ color: "#c32230" }}
266+
onClick={() => handleDelete(index)}
267+
/>,
268+
]
269+
: undefined
270+
}
271+
>
272+
<List.Item.Meta
273+
avatar={generateCommentAvatar(item)}
274+
title={
275+
<div onClick={() => props.onEvent("click")}>
276+
<a>{item?.user?.name}</a>
277+
<Tooltip
278+
title={
279+
dayjs(item?.createdAt).isValid()
280+
? dayjs(item?.createdAt).format("YYYY/M/D HH:mm:ss")
281+
: trans("comment.dateErr")
282+
}
283+
placement="bottom"
284+
>
285+
<span
286+
style={{
287+
paddingLeft: "5px",
288+
color: "#999",
289+
fontSize: "11px",
290+
}}
291+
>
292+
{dayjs(item?.createdAt).isValid()
293+
? dayjs(item?.createdAt).fromNow()
294+
: trans("comment.dateErr")}
295+
</span>
296+
</Tooltip>
297+
</div>
298+
}
299+
description={<span>{item?.value}</span>}
300+
/>
301+
</List.Item>
330302
)}
331-
</Mentions>
332-
<Button
333-
type="primary"
334-
style={{
335-
width: "98%",
336-
margin: "10px 10px 10px 5px",
337-
// position: "fixed",
338-
// bottom: "0px",
339-
}}
340-
onClick={handleSubmit}
341-
disabled={context === ""}
342-
>
343-
{buttonText}
344-
</Button>
345-
</>
346-
) : (
347-
""
348-
)}
303+
</VirtualList>
304+
</List>
305+
{sendCommentAble ? (
306+
<div style={{position: "sticky", bottom: 0, background: style.background}}>
307+
<Mentions
308+
style={{
309+
width: "100%",
310+
height: 50,
311+
}}
312+
onSearch={onSearch}
313+
prefix={Object.keys(MentionListData)}
314+
onChange={onChange}
315+
onSelect={(option: any) => {
316+
dispatch(changeChildAction("mentionName", option?.value, false));
317+
props.onEvent("mention");
318+
}}
319+
value={context}
320+
rows={2}
321+
onPressEnter={onPressEnter}
322+
placeholder={placeholder}
323+
>
324+
{(MentionListData[prefix] || []).map(
325+
(value: string, index: number) => (
326+
<Mentions.Option key={index.toString()} value={value}>
327+
{value}
328+
</Mentions.Option>
329+
)
330+
)}
331+
</Mentions>
332+
<Button
333+
type="primary"
334+
style={{
335+
width: "100%",
336+
marginTop: "10px",
337+
}}
338+
onClick={handleSubmit}
339+
disabled={context === ""}
340+
>
341+
{buttonText}
342+
</Button>
343+
</div>
344+
) : (
345+
""
346+
)}
347+
</div>
349348
</div>
350349
);
351350
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy