-
Notifications
You must be signed in to change notification settings - Fork 945
fix(ChatPromptSubmit): proxy event to stop and reload emits
#5400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ChatPromptSubmit): proxy event to stop and reload emits
#5400
Conversation
β¦al events can be consumed
commit: |
|
I'm having a hard-time understand your issue here, do you have the issue in a real environment when using Also, I tried your changes locally but adding this event still logs |
@benjamincanac This has nothing to do with To put it simply, onClick implemented in ChatPromptSubmit will call stop and reload based on the message status but will not send the event instance. Developers cannot implement operations such as preventing bubbling and consuming default events in onStop and onReload implemented by themselves. The final effect is that users will be able to call import { defineComponent, ref } from "vue";
import { type ChatPromptSubmitProps } from "@nuxt/ui/components/ChatPromptSubmit.vue";
import { UChatPrompt, UChatPromptSubmit } from "#components";
let timer: any;
export default defineComponent({
setup() {
const input = ref("value");
const status = ref<ChatPromptSubmitProps["status"]>("ready");
const handleSubmit = (e: Event) => {
e.preventDefault();
console.log("handleSubmit");
if (timer) clearTimeout(timer);
status.value = "streaming";
timer = setTimeout(() => {
status.value = "error";
}, 3600);
};
const handleStop = (event) => {
console.log("handleStop");
status.value = "ready";
event.preventDefault(); // this is the key place
};
const handleReload = (event) => {
console.log("handleReload");
status.value = "ready";
event.preventDefault(); // this is the key place
};
return () => {
return (
<div>
<UChatPrompt
modelValue={input.value}
onSubmit={handleSubmit}
style={{ height: "5rem", paddingLeft: "0" }}
>
{{
footer: () => (
<div class="chat_prompt_buttons">
<div style={{ flex: 1 }}></div>
<UChatPromptSubmit
status={status.value} // simulation state
onStop={handleStop}
onReload={handleReload}
/>
</div>
),
}}
</UChatPrompt>
</div>
);
};
},
}); |
|
@benjamincanac is there anything I can do? |
stop and reload emits
[ChatPromptSubmit] emits provides event externally so that external events can be consumed
π Linked issue
The problem is explained in the description.
β Type of change
π Description
Reproduction: https://codesandbox.io/p/devbox/sweet-dirac-7hpdy2?file=%2Fapp%2Fapp.tsx
Due to the event bubble, when
UChatPromptnestsUChatPromptSubmit, theonStopandonReloadofUChatPromptSubmitdo not consume the event, which will bubble to theonSubmitevent ofUChatPrompt, causing some side effects (onSubmitevent is called multiple times as shown in the figure below).π Checklist