fix: incorrect checkbox state after removing checked items #4549 (#4552)

Co-authored-by: Anubhav Singh <anubhav@mail.techindika.com>
pull/4561/head
Anubhav Singh 2 months ago committed by GitHub
parent 44df17aecc
commit 194a49367c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,5 +1,5 @@
import { Checkbox } from "@usememos/mui";
import { useContext, useState } from "react";
import { useContext } from "react";
import { markdownServiceClient } from "@/grpcweb";
import { useMemoStore } from "@/store/v1";
import { Node, TaskListItemNode } from "@/types/proto/api/v1/markdown_service";
@ -19,7 +19,6 @@ interface Props {
const TaskListItem: React.FC<Props> = ({ node, complete, children }: Props) => {
const context = useContext(RendererContext);
const memoStore = useMemoStore();
const [checked, setChecked] = useState(complete);
const handleCheckboxChange = async (on: boolean) => {
if (context.readonly || !context.memoName) {
@ -35,13 +34,12 @@ const TaskListItem: React.FC<Props> = ({ node, complete, children }: Props) => {
},
["content"],
);
setChecked(on);
};
return (
<li className={cn("w-full grid grid-cols-[24px_1fr]")}>
<span className="w-6 h-6 flex justify-start items-center">
<Checkbox size="sm" checked={checked} disabled={context.readonly} onChange={(e) => handleCheckboxChange(e.target.checked)} />
<Checkbox size="sm" checked={complete} disabled={context.readonly} onChange={(e) => handleCheckboxChange(e.target.checked)} />
</span>
<p className={cn(complete && "line-through opacity-80")}>
{children.map((child, index) => (

Loading…
Cancel
Save