Skip to content

Commit 9ba11fd

Browse files
committed
fix: User input dialog follows trigger button position on desktop
1 parent 61544b4 commit 9ba11fd

2 files changed

Lines changed: 71 additions & 6 deletions

File tree

ui/src/components/ai-chat/component/inline-params/index.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
:formfield-list="fieldList"
1616
/>
1717
</template>
18-
<el-button style="padding: 8px" v-if="dialogFields.length > 0" @click="emit('openDialog')">
18+
<el-button
19+
ref="triggerBtnRef"
20+
style="padding: 8px"
21+
v-if="dialogFields.length > 0"
22+
@click="emit('openDialog')"
23+
>
1924
<AppIcon iconName="app-all-menu"></AppIcon>
2025
</el-button>
2126
</div>
@@ -38,6 +43,8 @@ const props = defineProps<{
3843
3944
const emit = defineEmits(['update:formData', 'openDialog'])
4045
46+
const triggerBtnRef = ref()
47+
4148
const fieldList = ref<FormField[]>([])
4249
const formValue = ref<Dict<any>>({})
4350
const setting = ref<{ exposed_fields: string[]; menu_title: string }>({
@@ -196,6 +203,7 @@ const show = (field: FormField) => {
196203
}
197204
198205
defineExpose({
206+
triggerBtnRef,
199207
validate: () => {
200208
for (const field of fieldList.value) {
201209
if (!show(field)) {

ui/src/components/ai-chat/index.vue

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,26 @@
77
height: firsUserInput ? '100%' : undefined,
88
}"
99
>
10-
<div
11-
v-show="showUserInputContent"
12-
:class="firsUserInput ? 'firstUserInput' : 'popperUserInput'"
13-
>
10+
<div v-if="showUserInputContent && firsUserInput" class="firstUserInput">
11+
<UserForm
12+
v-model:api_form_data="api_form_data"
13+
v-model:form_data="form_data"
14+
:excludeFields="inlineExposedFields"
15+
:title="
16+
applicationDetails?.work_flow?.nodes?.find((v: any) => v.id === 'base-node')?.properties
17+
?.user_input_field_list_setting?.menu_title ||
18+
applicationDetails?.work_flow?.nodes?.find((v: any) => v.id === 'base-node')?.properties
19+
?.user_input_config?.title
20+
"
21+
:application="applicationDetails"
22+
:type="type"
23+
:first="firsUserInput"
24+
@confirm="UserFormConfirm"
25+
@cancel="UserFormCancel"
26+
ref="userFormRef"
27+
/>
28+
</div>
29+
<div v-if="showUserInputContent && !firsUserInput && isNarrow" class="popperUserInput">
1430
<UserForm
1531
v-model:api_form_data="api_form_data"
1632
v-model:form_data="form_data"
@@ -29,6 +45,42 @@
2945
ref="userFormRef"
3046
/>
3147
</div>
48+
<el-popover
49+
v-if="!firsUserInput && !isNarrow"
50+
v-model:visible="showUserInput"
51+
:virtual-ref="triggerEl"
52+
virtual-triggering
53+
trigger="manual"
54+
placement="top-start"
55+
:offset="0"
56+
:width="400"
57+
:show-arrow="false"
58+
popper-class="bare-popper"
59+
:popper-style="{
60+
background: 'transparent',
61+
border: 'none',
62+
padding: '0',
63+
boxShadow: 'none',
64+
}"
65+
>
66+
<UserForm
67+
v-model:api_form_data="api_form_data"
68+
v-model:form_data="form_data"
69+
:excludeFields="inlineExposedFields"
70+
:title="
71+
applicationDetails?.work_flow?.nodes?.find((v: any) => v.id === 'base-node')?.properties
72+
?.user_input_field_list_setting?.menu_title ||
73+
applicationDetails?.work_flow?.nodes?.find((v: any) => v.id === 'base-node')?.properties
74+
?.user_input_config?.title
75+
"
76+
:application="applicationDetails"
77+
:type="type"
78+
:first="firsUserInput"
79+
@confirm="UserFormConfirm"
80+
@cancel="UserFormCancel"
81+
ref="userFormRef"
82+
/>
83+
</el-popover>
3284
<template v-if="!(isUserInput || isAPIInput) || !firsUserInput || type === 'log'">
3385
<el-scrollbar ref="scrollDiv" @scroll="handleScrollTop">
3486
<div
@@ -266,7 +318,7 @@ const isMobile = computed(() => {
266318
return common.isMobile() || mode === 'embed' || mode === 'mobile'
267319
})
268320
269-
const isNarrow = computed(() => rootWidth.value > 0 && rootWidth.value < 678)
321+
const isNarrow = computed(() => rootWidth.value > 0 && rootWidth.value < 768)
270322
271323
const maxExposed = computed(() => (isNarrow.value ? 1 : 3))
272324
const inlineExposedFields = computed<string[]>(() =>
@@ -276,6 +328,11 @@ const inlineExposedFields = computed<string[]>(() =>
276328
).slice(0, maxExposed.value),
277329
)
278330
331+
const triggerEl = computed<HTMLElement | undefined>(() => {
332+
const btn = inlineParamsRef.value?.triggerBtnRef as any
333+
return btn?.$el ?? btn
334+
})
335+
279336
const scrollDiv = ref()
280337
const dialogScrollbar = ref()
281338
const loading = ref(false)

0 commit comments

Comments
 (0)