-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix table block cell selection #16653
Conversation
33e5ad2
to
41f8824
Compare
@@ -377,15 +377,24 @@ export class TableEdit extends Component { | |||
}; | |||
|
|||
const cellClasses = classnames( { 'is-selected': isSelected } ); | |||
const richTextClassName = 'wp-block-table__cell-content'; |
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.
Could this just be rich-text
?
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.
It could be, it's an existing class name though, not something new, so I don't see a big reason to change it.
// user may click inside a cell, but outside of the RichText, resulting in nothing happening. | ||
const richTextElement = event && event.target && event.target.querySelector( `.${ richTextClassName }` ); | ||
if ( richTextElement ) { | ||
richTextElement.focus(); |
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.
I removed this line, and the e2e test still passes.
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.
Thanks for spotting that, the selector used in the test was wrong, now fixed.
41f8824
to
0e6326d
Compare
This one should be good for re-review. |
await insertBlock( 'Table' ); | ||
|
||
// Create the table. | ||
const createButton = await page.$x( createButtonSelector ); |
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.
Also here, could the utility function clickButton
be used?
// Add lots of text to the first cell. | ||
await page.click( '.wp-block-table__cell-content' ); | ||
await page.keyboard.type( | ||
`Some long text that will wrap onto multiple lines.` |
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.
You could also use line breaks here. Press Enter
or type \n
.
|
||
// Click in the top left corner of the second cell and type some text. | ||
await page.mouse.click( secondCellX, secondCellY ); | ||
await page.keyboard.type( 'This content is in the second cell.' ); |
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.
I usually try to avoid long strings of text where one single character may be enough to test. Not sure if that actually makes much difference though. :)
0e6326d
to
c451522
Compare
* Forward focus to child RichText when a table cell is selected * Add e2e tests * Update e2e test to ensure cell is clicked instead of the rich text
* Forward focus to child RichText when a table cell is selected * Add e2e tests * Update e2e test to ensure cell is clicked instead of the rich text
Description
Fixes #14904
Fixes an issue where table block cells are difficult to select in some situations.
This issue particularly occurs when a cell is alongside another that has a lot of text content, and also particularly noticable when Fixed Width Cells is enabled.
How has this been tested?
Added an e2e test
Manual testing
Expected Result (in this branch)
The cell is selected
Actual Result (in current master)
The cell is not selected
Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: