Skip to content

Commit

Permalink
fix: Non-enabled state triggers rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
zjxxxxxxxxx committed Dec 7, 2024
1 parent 345fa6b commit f728a1f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/empty-cherries-pay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@open-editor/client': patch
---

Fix for non-enabled state triggering rendering
5 changes: 4 additions & 1 deletion packages/client/src/bridge/boxModelBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import { crossIframeBridge } from '../utils/crossIframeBridge';
import { isTopWindow, whenTopWindow } from '../utils/topWindow';
import { onMessage, postMessage } from '../utils/message';
import { type BoxLines, type BoxRect, getBoxModel } from '../inspector/getBoxModel';
import { inspectorState } from '../inspector/inspectorState';
import { BOX_MODEL_CROSS_IFRAME } from '../constants';

export const boxModelBridge = crossIframeBridge<[BoxRect, BoxLines]>({
setup() {
onMessage<[BoxRect, BoxLines]>(BOX_MODEL_CROSS_IFRAME, (args) => {
boxModelBridge.emit(args, isTopWindow);
if (inspectorState.isEnable) {
boxModelBridge.emit(args, isTopWindow);
}
});
},
emitMiddlewares: [
Expand Down
5 changes: 4 additions & 1 deletion packages/client/src/bridge/codeSourceBridge.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { crossIframeBridge } from '../utils/crossIframeBridge';
import { topWindow, whenTopWindow } from '../utils/topWindow';
import { onMessage, postMessage } from '../utils/message';
import { inspectorState } from '../inspector/inspectorState';
import { type CodeSource } from '../resolve';
import { CODE_SOURCE_CROSS_IFRAME } from '../constants';

export const codeSourceBridge = crossIframeBridge<[CodeSource | undefined]>({
setup() {
onMessage<[CodeSource | undefined]>(CODE_SOURCE_CROSS_IFRAME, (args) => {
codeSourceBridge.emit(args, true);
if (inspectorState.isEnable) {
codeSourceBridge.emit(args, true);
}
});
},
emitMiddlewares: [
Expand Down

0 comments on commit f728a1f

Please sign in to comment.