Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e17a150

Browse files
committedNov 4, 2024
memoize hasChildren variable
1 parent f020af3 commit e17a150

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed
 

‎src/api/ui/views/task.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,8 @@ export function Task({ item, state: props }: { item: MarkdownTaskItem; state: Ta
125125
[eState.content, item, props.rows]
126126
);
127127

128-
const [collapsed, setCollapsed] = useState<boolean>(false);
129-
const hasChildren = item.$elements.length > 0;
130-
useEffect(() => {
131-
setCollapsed(!collapsed);
132-
}, []);
128+
const [collapsed, setCollapsed] = useState<boolean>(true);
129+
const hasChildren = useMemo(() => item.$elements.length > 0, [item, item.$elements, item.$elements.length]);
133130

134131
return (
135132
<li

‎src/ui/fields/fields.css

+4-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
border-bottom-left-radius: inherit;
2929
user-select: none;
3030
}
31-
span.datacore-editable-outer, span.datacore-editable-outer textarea {
32-
width: 100% !important;
33-
display: inline-block !important;
31+
span.datacore-editable-outer,
32+
span.datacore-editable-outer textarea {
33+
width: 100% !important;
34+
display: inline-block !important;
3435
}
3536
.datacore-field .field-value {
3637
display: inline-block;

0 commit comments

Comments
 (0)
Please sign in to comment.