https://bugs.kde.org/show_bug.cgi?id=527695

            Bug ID: 527695
           Summary: Clicking a task list checkbox (to check or uncheck)
                    changes the visual state in some cases but **the
                    change is not saved** to the Markdown file. When
                    reopening the note, the checkbox reverts to its
                    previous state. Typing `x` manually inside the
                    brackets,
    Classification: Applications
           Product: Marknote
      Version First 1.6.0
       Reported In:
          Platform: Garuda Linux
                OS: Linux
            Status: REPORTED
          Severity: major
          Priority: NOR
         Component: General
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
  Target Milestone: ---

Created attachment 197564
  --> https://bugs.kde.org/attachment.cgi?id=197564&action=edit
Makes clicking a task list checkbox update the model and save the change to the
Markdown file. Currently the click has no effect on persistence: without
triggering the command, the checkmark is not sa

# Bug Report

**Product:** Marknote  
**Component:** Block list / task list item (`BlockListItem.qml`)  
**Version:** 1.6.0 and current master  
**Type:** Functional bug / change not persisted

## Summary

Clicking a task list checkbox (to check or uncheck) changes the visual state in
some cases but **the change is not saved** to the Markdown file. When reopening
the note, the checkbox reverts to its previous state. Typing `x` manually
inside the brackets, on the other hand, works and persists correctly.

## Steps to reproduce

1. Open a note containing a task list item, for example:
  `- [ ] Do something`
1. Click directly on the checkbox of that item.
1. Wait for autosave or close and reopen the note.
1. Observe that the checkbox **does not remain checked** (it goes back to `[
]`).

## Observed behavior

In `src/qml/BlockListItem.qml`, the `CheckBox` only had a read binding:

```qml
checked: blockData.isChecked
```

There was no `onClicked` handler. The serializer
(`src/mdserializer/mdserializer.cpp`) only writes `- [x]` when
`blockData.isChecked` is true; without a command updating the model/structure
of the block, that value is never changed persistently. The existing
transformation via keyboard works through `CommandManager::autoTransform()` (by
typing `x` inside the brackets), but clicking the checkbox never called
`CommandManager.transformToChecklist(...)`.

## Expected behavior

Clicking the task list checkbox should check or uncheck the item and **save the
change** to the Markdown file (persist after reopening the note). Undo should
work normally (one step per click).

## Fix

In `src/qml/BlockListItem.qml`, handle the checkbox click and call the command
that transforms the task list item to the new state. The **child paragraph** of
the list item (where the text lives) must be passed, along with that
paragraph's current text; the command finds the `ListItem` via `parent()` of
the passed block. Since the file did not import the application module yet,
`import org.kde.marknote` is also added to make `CommandManager` available.

```qml
CheckBox {
    id: checkbox
    ...
    checked: blockData.isChecked
    onClicked: {
        if (checked === blockData.isChecked)
            return;
        const paragraph = root.block.children[0];
        if (paragraph)
            CommandManager.transformToChecklist(paragraph, checked,
paragraph.data.md);
    }
}
```

Changed file: `src/qml/BlockListItem.qml`

## Note

The command already existed and was used elsewhere; the fix simply wires it to
the checkbox click. It uses the same mechanism as the keyboard transformation,
ensuring consistency and correct undo/redo behavior.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to