Skip to content

Commit ebd2b76

Browse files
committed
fix inkDialog open issue
1 parent 8f2916e commit ebd2b76

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed

.changeset/major-lands-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@inkcre/web-design": patch
3+
---
4+
5+
Fix: InkDialog open issue

packages/web-design/src/components/AGENTS.comp-scss.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
## Best Practices
44

5-
- Use UnoCSS when style is simple (e.g. layout, animation)
5+
- Use UnoCSS for simple styles (e.g. layout)
6+
- Make use of morden CSS features
7+
- Parent selectors (eg. `.card:has(input:checked)`)
68

79
### Use Design Tokens
810

packages/web-design/src/components/inkDialog/inkDialog.vue

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script setup lang="ts">
2-
import { computed, watch, provide, readonly } from "vue";
3-
import { useAsyncState } from "@vueuse/core";
2+
import { ref, computed, watch, provide, readonly } from "vue";
43
import {
54
inkDialogProps,
65
inkDialogEmits,
@@ -14,31 +13,28 @@ const props = defineProps(inkDialogProps);
1413
const emit = defineEmits(inkDialogEmits);
1514
const i18n = useOptionalI18n();
1615
17-
const {
18-
state: currentValue,
19-
isLoading: isDialogLoading,
20-
execute,
21-
} = useAsyncState(
22-
async () => {
23-
const value = props.modelValue;
24-
return value instanceof Promise ? await value : value;
25-
},
26-
false,
27-
{
28-
immediate: true,
29-
resetOnExecute: false,
16+
const currentValue = ref(false);
17+
const isPromiseLoading = ref(false);
18+
19+
const updateCurrentValue = async (value: boolean | Promise<boolean>) => {
20+
if (value instanceof Promise) {
21+
isPromiseLoading.value = true;
22+
try {
23+
currentValue.value = await value;
24+
} finally {
25+
isPromiseLoading.value = false;
26+
}
27+
} else {
28+
currentValue.value = value;
3029
}
31-
);
30+
};
3231
3332
watch(
3433
() => props.modelValue,
35-
async () => {
36-
if (props.modelValue instanceof Promise) {
37-
await execute();
38-
} else {
39-
currentValue.value = props.modelValue;
40-
}
41-
}
34+
(val) => {
35+
updateCurrentValue(val);
36+
},
37+
{ immediate: true }
4238
);
4339
4440
const open = computed({
@@ -48,7 +44,7 @@ const open = computed({
4844
},
4945
});
5046
51-
const isLoading = computed(() => isDialogLoading.value);
47+
const isLoading = computed(() => isPromiseLoading.value);
5248
5349
// Provide loading state to buttons via inject
5450
provide("isLoading", readonly(isLoading));

packages/web-design/src/components/inkPopup/inkPopup.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.ink-popup-overlay {
2-
position: absolute;
2+
position: fixed;
33
top: 0;
44
left: 0;
55
right: 0;
@@ -9,7 +9,7 @@
99
}
1010

1111
.ink-popup {
12-
position: absolute;
12+
position: fixed;
1313
z-index: 10;
1414
background-color: sys-var(color, surface, base);
1515
padding: sys-var(space, md);

0 commit comments

Comments
 (0)