-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
List View: Account for text fields in shortcut handler #61583
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,26 +36,10 @@ test.describe( 'Block Renaming', () => { | |
page, | ||
pageUtils, | ||
} ) => { | ||
// Turn on block list view by default. | ||
await editor.setPreferences( 'core', { | ||
showListViewByDefault: true, | ||
} ); | ||
Comment on lines
-40
to
-42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just setting the preference doesn't open the list view. It needs a page refresh or manual trigger. |
||
|
||
const listView = page.getByRole( 'treegrid', { | ||
name: 'Block navigation structure', | ||
} ); | ||
|
||
await editor.insertBlock( { | ||
name: 'core/group', | ||
attributes: { content: 'First Paragraph' }, | ||
} ); | ||
await editor.insertBlock( { name: 'core/group' } ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I decided to just insert a group block instead of converting it. @getdave, do we need to test a nested block, or is it okay this way? |
||
|
||
// Select via keyboard. | ||
await pageUtils.pressKeys( 'primary+a' ); | ||
|
||
// Convert to a Group block which supports renaming. | ||
await editor.clickBlockOptionsMenuItem( 'Group' ); | ||
|
||
await editor.clickBlockOptionsMenuItem( 'Rename' ); | ||
|
||
const renameMenuItem = page.getByRole( 'menuitem', { | ||
|
@@ -107,11 +91,18 @@ test.describe( 'Block Renaming', () => { | |
'false' | ||
); | ||
|
||
// Check custom name reflected in List View. | ||
listView.getByRole( 'link', { | ||
name: 'My new name', | ||
await pageUtils.pressKeys( 'access+o' ); | ||
const listView = page.getByRole( 'treegrid', { | ||
name: 'Block navigation structure', | ||
} ); | ||
|
||
await expect( | ||
listView.getByRole( 'link', { | ||
name: 'My new name', | ||
} ), | ||
'should reflect custom name in List View' | ||
).toBeVisible(); | ||
|
||
await expect.poll( editor.getBlocks ).toMatchObject( [ | ||
{ | ||
name: 'core/group', | ||
|
@@ -123,7 +114,8 @@ test.describe( 'Block Renaming', () => { | |
}, | ||
] ); | ||
|
||
// Re-trigger the rename dialog. | ||
// Re-trigger the rename dialog from the List View. | ||
await listView.getByRole( 'button', { name: 'Options' } ).click(); | ||
await renameMenuItem.click(); | ||
|
||
// Expect modal input to contain the custom name. | ||
|
@@ -142,10 +134,12 @@ test.describe( 'Block Renaming', () => { | |
|
||
await saveButton.click(); | ||
|
||
// Check the original block name to reflected in List View. | ||
listView.getByRole( 'link', { | ||
name: 'Group', | ||
} ); | ||
Comment on lines
-145
to
-148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just constructing a locator doesn't test anything, so the test never asserted values in the List View. This is fixed now. |
||
await expect( | ||
listView.getByRole( 'link', { | ||
name: 'Group', | ||
} ), | ||
'should reflect original name in List View' | ||
).toBeVisible(); | ||
|
||
// Expect block to have no custom name (i.e. it should be reset to the original block name). | ||
await expect.poll( editor.getBlocks ).toMatchObject( [ | ||
|
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.
@mcsf, @andrewserong, what do you think about this solution?
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 don't mind it, but for completeness' sake this is what my local branch looks like:
with the current draft commit message:
Both approaches probably carry some unknowns, I'll let you follow your intuition. :)
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 also considered fixing the issue locally for the "Rename" modal, but the same issue will affect other modals (e.g., "Create pattern") with text fields.
My thought was that consumers shouldn't care how list view handles shortcuts.
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.
Sounds good to me