mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
fix for dropdown
This commit is contained in:
@@ -39,7 +39,7 @@ export { Component } from "./component";
|
|||||||
export type { ComponentConstructor } from "./component";
|
export type { ComponentConstructor } from "./component";
|
||||||
export { useComponent, useState } from "./component_node";
|
export { useComponent, useState } from "./component_node";
|
||||||
export { status } from "./status";
|
export { status } from "./status";
|
||||||
export { reactive, markRaw, toRaw } from "./reactivity";
|
export { reactive, markRaw, toRaw, effect } from "./reactivity";
|
||||||
export { useEffect, useEnv, useExternalListener, useRef, useChildSubEnv, useSubEnv } from "./hooks";
|
export { useEffect, useEnv, useExternalListener, useRef, useChildSubEnv, useSubEnv } from "./hooks";
|
||||||
export { batched, EventBus, htmlEscape, whenReady, loadFile, markup } from "./utils";
|
export { batched, EventBus, htmlEscape, whenReady, loadFile, markup } from "./utils";
|
||||||
export {
|
export {
|
||||||
|
|||||||
@@ -131,6 +131,11 @@ function processSignals() {
|
|||||||
[...scheduledSignals.values()].map((s) => [...s.executionContexts]).flat()
|
[...scheduledSignals.values()].map((s) => [...s.executionContexts]).flat()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// schedule before context.update in case there is write operations during update
|
||||||
|
// todo: add a test in case there is write operations during update the test
|
||||||
|
// will break is scheduledSignals.clear(); is called after context.update();
|
||||||
|
// that writes
|
||||||
|
scheduledSignals.clear();
|
||||||
for (const ctx of [...scheduledContexts]) {
|
for (const ctx of [...scheduledContexts]) {
|
||||||
removeSignalsFromContext(ctx);
|
removeSignalsFromContext(ctx);
|
||||||
// custom unsubscribe depending on the context.
|
// custom unsubscribe depending on the context.
|
||||||
@@ -146,7 +151,6 @@ function processSignals() {
|
|||||||
popExecutionContext();
|
popExecutionContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scheduledSignals.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -263,7 +267,11 @@ function unsubscribeChildEffect(
|
|||||||
executionContext.meta.children.length = 0;
|
executionContext.meta.children.length = 0;
|
||||||
}
|
}
|
||||||
export function effect(fn: Function) {
|
export function effect(fn: Function) {
|
||||||
const parent = getExecutionContext();
|
let parent = getExecutionContext();
|
||||||
|
// todo: is it useful?
|
||||||
|
if (parent && !parent?.meta.children) {
|
||||||
|
parent = undefined!;
|
||||||
|
}
|
||||||
const executionContext: ExecutionContext = {
|
const executionContext: ExecutionContext = {
|
||||||
unsubcribe: (scheduledContexts: Set<ExecutionContext>) => {
|
unsubcribe: (scheduledContexts: Set<ExecutionContext>) => {
|
||||||
unsubscribeChildEffect(executionContext, scheduledContexts);
|
unsubscribeChildEffect(executionContext, scheduledContexts);
|
||||||
@@ -277,12 +285,13 @@ export function effect(fn: Function) {
|
|||||||
},
|
},
|
||||||
signals: new Set(),
|
signals: new Set(),
|
||||||
meta: {
|
meta: {
|
||||||
parent: getExecutionContext(),
|
parent: parent,
|
||||||
children: [],
|
children: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent.meta.children.push(executionContext);
|
// todo: is it useful?
|
||||||
|
parent.meta.children?.push?.(executionContext);
|
||||||
}
|
}
|
||||||
pushExecutionContext(executionContext);
|
pushExecutionContext(executionContext);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user