fix new element scene null leading to bugs after aligning

This commit is contained in:
Ryan Di 2023-06-23 21:31:28 +08:00
parent b7350f9707
commit dce6010b29
5 changed files with 24 additions and 16 deletions

View file

@ -245,6 +245,7 @@ import {
isTransparent,
easeToValuesRAF,
muteFSAbortError,
arrayToMap,
} from "../utils";
import {
ContextMenu,
@ -1094,6 +1095,12 @@ class App extends React.Component<AppProps, AppState> {
},
);
}
// update frame membership if needed
updateFrameMembershipOfSelectedElements(
this.scene.getElementsIncludingDeleted(),
this.state,
);
},
);
@ -3018,11 +3025,13 @@ class App extends React.Component<AppProps, AppState> {
!(isTextElement(element) && element.containerId)),
);
const elementsMap = arrayToMap(elements);
return getElementsAtPosition(elements, (element) =>
hitTest(element, this.state, this.frameNameBoundsCache, x, y),
).filter((element) => {
// hitting a frame's element from outside the frame is not considered a hit
const containingFrame = getContainingFrame(element);
const containingFrame = getContainingFrame(element, elementsMap);
return containingFrame && this.state.shouldRenderFrames
? isCursorInFrame({ x, y }, containingFrame)
: true;
@ -5845,7 +5854,10 @@ class App extends React.Component<AppProps, AppState> {
);
if (linearElement?.frameId) {
const frame = getContainingFrame(linearElement);
const frame = getContainingFrame(
linearElement,
arrayToMap(this.scene.getElementsIncludingDeleted()),
);
if (frame && linearElement) {
if (!elementOverlapsWithFrame(linearElement, frame)) {