Skip to content

Commit 85eb398

Browse files
committed
fix(bottomsheet): vue3 component fix
1 parent 2bdd17a commit 85eb398

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

src/bottomsheet/vue3/index.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { App, createApp } from 'nativescript-vue';
1+
import { createNativeView } from 'nativescript-vue';
22
import { Frame, View, ViewBase } from '@nativescript/core';
33
import { BottomSheetOptions } from '../bottomsheet';
44
import { ComponentCustomProperties } from '@vue/runtime-core';
@@ -34,18 +34,17 @@ const showSheet = (component, options: VueBottomSheetOptions) =>
3434
let navEntryInstance = createNativeView(
3535
component,
3636
Object.assign(
37-
{
38-
props: options.props
39-
},
37+
options.props ?? {},
4038
listeners
4139
)
42-
).mount();
40+
);
41+
navEntryInstance.mount();
4342

4443
const viewAttached = (options.view as View) ?? Frame.topmost().currentPage;
4544

4645
viewAttached.showBottomSheet(
4746
Object.assign({}, options, {
48-
view: navEntryInstance.$el.nativeView,
47+
view: navEntryInstance.nativeView,
4948
closeCallback: (...args) => {
5049
if (resolved) {
5150
return;
@@ -54,10 +53,8 @@ const showSheet = (component, options: VueBottomSheetOptions) =>
5453
if (navEntryInstance && navEntryInstance) {
5554
options.closeCallback && options.closeCallback.apply(undefined, args);
5655
resolve(...args);
57-
navEntryInstance.$emit('bottomsheet:close');
58-
navEntryInstance.$el = null;
59-
navEntryInstance = null;
60-
modalStack.splice(modalStack.length, 1);
56+
navEntryInstance.unmount();
57+
modalStack.pop();
6158
}
6259
}
6360
})
@@ -67,7 +64,7 @@ const showSheet = (component, options: VueBottomSheetOptions) =>
6764
const closeSheet = (...args) => {
6865
const modalPageInstanceInfo = modalStack[modalStack.length - 1];
6966
if (modalPageInstanceInfo) {
70-
modalPageInstanceInfo.$el.nativeView.closeBottomSheet(args);
67+
modalPageInstanceInfo.nativeView.closeBottomSheet(args);
7168
}
7269
};
7370

@@ -80,9 +77,6 @@ const BottomSheetPlugin = {
8077
}
8178
};
8279

83-
const createNativeView = (component: any, props?: any): App => createApp(component, props);
84-
85-
8680
interface VueBottomSheetOptions extends Partial<BottomSheetOptions> {
8781
view?: string | View;
8882
props?: any;

0 commit comments

Comments
 (0)