fix(task-item): fix read only checked handling #5952
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #3676
Changes Overview
onReadOnlyChecked
allows you to determine whether the checking/unchecking the task item should apply the change, or not.It did not work because:
Implementation Approach
Now it runs the logic inside the transaction where we have access to the current node, and we can either abort it as before if it returns
false
, or allow it to proceed with the transaction if it returnstrue
.Testing Done
Only manual testing whilst clicking in a browser.
Verification Steps
Configure your editor like this:
Then, ideally, open a couple of windows with a collaborative session running, and notice that you can check/uncheck the box in one window, but the change is not propagated to the other.
Additionally, if you want to have more logic (e.g. the kind of logic in #4521 - where the node descendent are checked for matching), it should be possible to observe the node is now the correct node, and can be matched if desired:
Additional Notes
There is also another bug, in the update method because it uses
checkbox.setAttribute('checked', 'checked')
andcheckbox.removeAttribute('checked')
which is not the correct way to change the state of a checkbox, should just becheckbox.checked = checked
.Should I add a fix to this PR? Maybe best in another one....
Update: I submitted a separate PR for that #5953
Checklist
Related Issues
#3676
#4521