Fix the issue where can()
check returns false
even when the command can be executed.
#5741
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.
Changes Overview
Fix the issue where
can()
check returnsfalse
even when the command is actually executable.Implementation Approach
When
chainCommand
is executed, multiple commands are run sequentially. The editor state used by later commands may depend on the preceding commands. Therefore, when executingcan()
,createChain
must ensure thatshouldDispatch
istrue
to prevent skipping operations ontr
.This fix effectively reverts the code changes from the pull request #3026 and resolves the issue #3025 caused by the
clearNodes
error.At the same time, it will also fix issue #3229 and issue #4057.
————————————————————————————————————————————————————
For more details, please refer to this issue #5721.
Testing Done
In the example default editor, add the
disabled
attribute to the heading and list action buttons. Before the change, if the cursor was positioned on a heading node, the list action buttons would remain disabled, even though the commands were actually available. After the change, the list action buttons will be displayed as enabled.Verification Steps
None.
Additional Notes
Checklist
Related Issues