Added internal comments to popup()
This commit is contained in:
parent
1613dafc39
commit
a516383c66
|
@ -204,13 +204,18 @@ export function popup<T extends Component>(
|
||||||
): { dispose: () => void } {
|
): { dispose: () => void } {
|
||||||
markRaw(component);
|
markRaw(component);
|
||||||
|
|
||||||
|
// Generate a unique ID for this popup.
|
||||||
const id = ++popupIdCount;
|
const id = ++popupIdCount;
|
||||||
|
|
||||||
|
// On disposal, remove this popup from the list of open popups.
|
||||||
const dispose = () => {
|
const dispose = () => {
|
||||||
// このsetTimeoutが無いと挙動がおかしくなる(autocompleteが閉じなくなる)。Vueのバグ?
|
// このsetTimeoutが無いと挙動がおかしくなる(autocompleteが閉じなくなる)。Vueのバグ?
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
popups.value = popups.value.filter(p => p.id !== id);
|
popups.value = popups.value.filter(p => p.id !== id);
|
||||||
}, 0);
|
}, 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Bundle the component, props, and events into a state object.
|
||||||
const state = {
|
const state = {
|
||||||
component,
|
component,
|
||||||
props,
|
props,
|
||||||
|
@ -218,8 +223,10 @@ export function popup<T extends Component>(
|
||||||
id,
|
id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Add the popup to the list of open popups.
|
||||||
popups.value.push(state);
|
popups.value.push(state);
|
||||||
|
|
||||||
|
// Return a function that can be called to close the popup.
|
||||||
return {
|
return {
|
||||||
dispose,
|
dispose,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue