fix(client): ウィジェットを追加できない問題を修正

Fix #7905
This commit is contained in:
syuilo 2021-10-23 11:17:41 +09:00
parent 4168addbb2
commit c6afc61c94
2 changed files with 25 additions and 15 deletions

View File

@ -7,6 +7,13 @@
-->
## 12.x.x (unreleased)
### Improvements
### Bugfixes
- クライアント: ウィジェットを追加できない問題を修正
## 12.93.1 (2021/10/23)
### Bugfixes

View File

@ -24,7 +24,7 @@
</template>
<script lang="ts">
import { defineComponent, onMounted, onUnmounted, nextTick, ref, watch, computed, toRefs } from 'vue';
import { defineComponent, onMounted, onUnmounted, nextTick, ref, watch, computed, toRefs, VNode } from 'vue';
import MkButton from '@client/components/ui/button.vue';
import * as os from '@client/os';
@ -140,6 +140,16 @@ export default defineComponent({
const menu = [];
let options = context.slots.default();
const pushOption = (option: VNode) => {
menu.push({
text: option.children,
active: v.value === option.props.value,
action: () => {
v.value = option.props.value;
},
});
};
for (const optionOrOptgroup of options) {
if (optionOrOptgroup.type === 'optgroup') {
const optgroup = optionOrOptgroup;
@ -148,23 +158,16 @@ export default defineComponent({
text: optgroup.props.label,
});
for (const option of optgroup.children) {
menu.push({
text: option.children,
active: v.value === option.props.value,
action: () => {
v.value = option.props.value;
},
});
pushOption(option);
}
} else if (Array.isArray(optionOrOptgroup.children)) { //
const fragment = optionOrOptgroup;
for (const option of fragment.children) {
pushOption(option);
}
} else {
const option = optionOrOptgroup;
menu.push({
text: option.children,
active: v.value === option.props.value,
action: () => {
v.value = option.props.value;
},
});
pushOption(option);
}
}