mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 18:26:05 +08:00
fix(editor): edgeless selected rect should be below the edgeless toolbar (#12370)
Close [BS-3512](https://linear.app/affine-design/issue/BS-3512/bug-note-选中状态会穿透-toolbar) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Added a new end-to-end test to verify that selection handles are visually and interactively layered beneath the edgeless element toolbar in the editor. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -102,9 +102,9 @@ export function getInternalViewExtensions() {
|
|||||||
InlinePresetViewExtension,
|
InlinePresetViewExtension,
|
||||||
|
|
||||||
// Widget
|
// Widget
|
||||||
|
// order will affect the z-index of the widget
|
||||||
DragHandleViewExtension,
|
DragHandleViewExtension,
|
||||||
EdgelessAutoConnectViewExtension,
|
EdgelessAutoConnectViewExtension,
|
||||||
EdgelessToolbarViewExtension,
|
|
||||||
FrameTitleViewExtension,
|
FrameTitleViewExtension,
|
||||||
KeyboardToolbarViewExtension,
|
KeyboardToolbarViewExtension,
|
||||||
LinkedDocViewExtension,
|
LinkedDocViewExtension,
|
||||||
@@ -118,6 +118,7 @@ export function getInternalViewExtensions() {
|
|||||||
EdgelessSelectedRectViewExtension,
|
EdgelessSelectedRectViewExtension,
|
||||||
EdgelessDraggingAreaViewExtension,
|
EdgelessDraggingAreaViewExtension,
|
||||||
NoteSlicerViewExtension,
|
NoteSlicerViewExtension,
|
||||||
|
EdgelessToolbarViewExtension,
|
||||||
|
|
||||||
// Fragment
|
// Fragment
|
||||||
DocTitleViewExtension,
|
DocTitleViewExtension,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
initEmptyEdgelessState,
|
initEmptyEdgelessState,
|
||||||
initThreeParagraphs,
|
initThreeParagraphs,
|
||||||
pressEnter,
|
pressEnter,
|
||||||
|
pressEscape,
|
||||||
waitNextFrame,
|
waitNextFrame,
|
||||||
} from '../../utils/actions/index.js';
|
} from '../../utils/actions/index.js';
|
||||||
import {
|
import {
|
||||||
@@ -25,6 +26,7 @@ import {
|
|||||||
assertEdgelessRemoteSelectedRect,
|
assertEdgelessRemoteSelectedRect,
|
||||||
assertEdgelessSelectedModelRect,
|
assertEdgelessSelectedModelRect,
|
||||||
assertEdgelessSelectedRect,
|
assertEdgelessSelectedRect,
|
||||||
|
assertRectExist,
|
||||||
assertSelectionInNote,
|
assertSelectionInNote,
|
||||||
} from '../../utils/asserts.js';
|
} from '../../utils/asserts.js';
|
||||||
import { test } from '../../utils/playwright.js';
|
import { test } from '../../utils/playwright.js';
|
||||||
@@ -464,3 +466,54 @@ test('should select shapes while moving selection', async ({ page }) => {
|
|||||||
|
|
||||||
await assertEdgelessSelectedRect(page, [100, 98, 212, 204]);
|
await assertEdgelessSelectedRect(page, [100, 98, 212, 204]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should the selected rect be below the edgeless element toolbar', async ({
|
||||||
|
page,
|
||||||
|
}) => {
|
||||||
|
await enterPlaygroundRoom(page);
|
||||||
|
await initEmptyEdgelessState(page);
|
||||||
|
await switchEditorMode(page);
|
||||||
|
|
||||||
|
const toolbar = page.locator('.edgeless-toolbar-container');
|
||||||
|
const toolbarRect = await toolbar.boundingBox();
|
||||||
|
assertRectExist(toolbarRect);
|
||||||
|
|
||||||
|
await actions.addNote(page, 'hello', toolbarRect.x, toolbarRect.y - 20);
|
||||||
|
await pressEscape(page, 3);
|
||||||
|
|
||||||
|
await page.mouse.click(toolbarRect.x, toolbarRect.y - 20);
|
||||||
|
|
||||||
|
const selectedRect = page.locator('.affine-edgeless-selected-rect');
|
||||||
|
await expect(selectedRect).toBeVisible();
|
||||||
|
|
||||||
|
const brHandle = selectedRect.getByLabel('bottom-right');
|
||||||
|
const brHandleRect = await brHandle.boundingBox();
|
||||||
|
assertRectExist(brHandleRect);
|
||||||
|
|
||||||
|
// make sure the position of br handle is inside the toolbar
|
||||||
|
expect(
|
||||||
|
brHandleRect.x > toolbarRect.x &&
|
||||||
|
brHandleRect.x < toolbarRect.x + toolbarRect.width &&
|
||||||
|
brHandleRect.y > toolbarRect.y &&
|
||||||
|
brHandleRect.y < toolbarRect.y + toolbarRect.height
|
||||||
|
).toBe(true);
|
||||||
|
|
||||||
|
const brHandleCenter = [
|
||||||
|
brHandleRect.x + brHandleRect.width / 2,
|
||||||
|
brHandleRect.y + brHandleRect.height / 2,
|
||||||
|
];
|
||||||
|
|
||||||
|
// get element from the center of br handle
|
||||||
|
const topElement = await page.evaluate(brHandleCenter => {
|
||||||
|
const element = document.elementFromPoint(
|
||||||
|
brHandleCenter[0],
|
||||||
|
brHandleCenter[1]
|
||||||
|
);
|
||||||
|
if (!element) {
|
||||||
|
throw new Error('element not found');
|
||||||
|
}
|
||||||
|
return element.tagName;
|
||||||
|
}, brHandleCenter);
|
||||||
|
|
||||||
|
expect(topElement).toBe('EDGELESS-TOOLBAR-WIDGET');
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user