fix(core): should focus when clicking sidebar button (#9339)
This commit is contained in:
@@ -51,6 +51,7 @@ export const MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>(
|
|||||||
data-active={active}
|
data-active={active}
|
||||||
data-disabled={disabled}
|
data-disabled={disabled}
|
||||||
data-collapsible={collapsible}
|
data-collapsible={collapsible}
|
||||||
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
{icon && (
|
{icon && (
|
||||||
<div className={styles.iconsContainer} data-collapsible={collapsible}>
|
<div className={styles.iconsContainer} data-collapsible={collapsible}>
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export function QuickSearchInput({ onClick, ...props }: QuickSearchInputProps) {
|
|||||||
{...props}
|
{...props}
|
||||||
className={clsx([props.className, styles.root])}
|
className={clsx([props.className, styles.root])}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
|
tabIndex={0}
|
||||||
>
|
>
|
||||||
<SearchIcon className={styles.icon} />
|
<SearchIcon className={styles.icon} />
|
||||||
<span className={styles.quickSearchBarEllipsisStyle}>
|
<span className={styles.quickSearchBarEllipsisStyle}>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import { test } from '@affine-test/kit/playwright';
|
import { test } from '@affine-test/kit/playwright';
|
||||||
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
|
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
|
||||||
import {
|
import {
|
||||||
|
copyByKeyboard,
|
||||||
|
pasteByKeyboard,
|
||||||
|
selectAllByKeyboard,
|
||||||
withCtrlOrMeta,
|
withCtrlOrMeta,
|
||||||
writeTextToClipboard,
|
writeTextToClipboard,
|
||||||
} from '@affine-test/kit/utils/keyboard';
|
} from '@affine-test/kit/utils/keyboard';
|
||||||
@@ -587,3 +590,30 @@ test('can use slash menu to insert an external link', async ({ page }) => {
|
|||||||
link
|
link
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Paste content with keyboard', async ({ page }) => {
|
||||||
|
await openHomePage(page);
|
||||||
|
await waitForEditorLoad(page);
|
||||||
|
await clickNewPageButton(page, 'Test');
|
||||||
|
|
||||||
|
// goto main content
|
||||||
|
await page.keyboard.press('Enter');
|
||||||
|
|
||||||
|
// input hello world to editor
|
||||||
|
await page.keyboard.type('hello world', {
|
||||||
|
delay: 50,
|
||||||
|
});
|
||||||
|
|
||||||
|
await selectAllByKeyboard(page);
|
||||||
|
await copyByKeyboard(page);
|
||||||
|
|
||||||
|
const quickSearchButton = page.locator(
|
||||||
|
'[data-testid=slider-bar-quick-search-button]'
|
||||||
|
);
|
||||||
|
await quickSearchButton.click();
|
||||||
|
const quickSearch = page.locator('[data-testid=cmdk-quick-search]');
|
||||||
|
await expect(quickSearch).toBeVisible();
|
||||||
|
|
||||||
|
await pasteByKeyboard(page);
|
||||||
|
await expect(page.locator('[cmdk-input]')).toHaveValue('hello world');
|
||||||
|
});
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ export async function pasteByKeyboard(page: Page) {
|
|||||||
await keyUpCtrlOrMeta(page);
|
await keyUpCtrlOrMeta(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function selectAllByKeyboard(page: Page) {
|
||||||
|
await keyDownCtrlOrMeta(page);
|
||||||
|
await page.keyboard.press('a', { delay: 50 });
|
||||||
|
await keyUpCtrlOrMeta(page);
|
||||||
|
}
|
||||||
|
|
||||||
export async function writeTextToClipboard(page: Page, text: string) {
|
export async function writeTextToClipboard(page: Page, text: string) {
|
||||||
// paste the url
|
// paste the url
|
||||||
await page.evaluate(
|
await page.evaluate(
|
||||||
|
|||||||
Reference in New Issue
Block a user