New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that a selection exists before attempting to execCommand #2143
Ensure that a selection exists before attempting to execCommand #2143
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2143 +/- ##
==========================================
- Coverage 24.23% 24.21% -0.03%
==========================================
Files 142 142
Lines 4460 4465 +5
Branches 756 758 +2
==========================================
Hits 1081 1081
- Misses 2854 2857 +3
- Partials 525 527 +2
Continue to review full report at Codecov.
|
blocks/library/table/table-block.js
Outdated
function isTableSelected( editor ) { | ||
return editor.dom.getParent( | ||
editor.selection.getStart( true ), | ||
'table' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know in this case that the table ancestor here is from this table block, and not another table on the page?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. DomUtils.getParent can take a root node as the third parameter so I'll set it to the editor container.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turned out that it needed to be the parent of the editor body otherwise it would not consider the table. Otherwise I think this issue is fixed.
764d5ef
to
9b48343
Compare
Thanks for the fix. It works well for me. I added the table back to the demo content (#1806). This PR should close a few other issues; I've edited them into the original post. Let's wait until after today's release to merge it though, so we get some testing ahead of a release. |
…github.com:WordPress/gutenberg into fix/1751-ensure-table-selection-before-execCommand
In normal TinyMCE the table toolbar is not shown unless a table is selected. For the table block we want to always show the toolbar even when the editor does not have a table selected so we have to check if a selection is present and supply a default selection when one is not available.