mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-02 01:49:51 +08:00
feat(editor): improve select perf (#15353)
maybe fix #12675 #### PR Dependency Tree * **PR #15353** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved block selection updates so selected states refresh reliably. - Corrected selected-block ordering and duplicate handling. - Improved toolbar positioning accuracy and reduced unnecessary layout recalculations. - Adjusted toolbar animation behavior for surface-based tools. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -146,7 +146,16 @@ export class AffineToolbarWidget extends WidgetComponent {
|
||||
}
|
||||
|
||||
setReferenceElementWithBlocks(blocks: BlockComponent[]) {
|
||||
const getClientRects = () => blocks.map(e => e.getBoundingClientRect());
|
||||
let cachedClientRects: DOMRect[] | null = null;
|
||||
const getClientRects = () => {
|
||||
if (!cachedClientRects) {
|
||||
cachedClientRects = blocks.map(e => e.getBoundingClientRect());
|
||||
requestAnimationFrame(() => {
|
||||
cachedClientRects = null;
|
||||
});
|
||||
}
|
||||
return cachedClientRects;
|
||||
};
|
||||
|
||||
this.referenceElement$.value = blocks.length
|
||||
? () => ({
|
||||
|
||||
@@ -56,7 +56,7 @@ export function autoUpdatePosition(
|
||||
flavour: string,
|
||||
placement: ToolbarPlacement,
|
||||
sideOptions: Partial<SideObject> | null,
|
||||
options: AutoUpdateOptions = { elementResize: false, animationFrame: true }
|
||||
options: AutoUpdateOptions = { elementResize: false }
|
||||
) {
|
||||
const isInline = flavour === 'affine:note';
|
||||
const hasSurfaceScope = flavour.includes('surface');
|
||||
@@ -147,7 +147,7 @@ export function autoUpdatePosition(
|
||||
() => {
|
||||
update().catch(console.error);
|
||||
},
|
||||
options
|
||||
{ animationFrame: hasSurfaceScope, ...options }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user