[🛠️ Fix] Issue #32 & #33

1. [/] 为 Revive 元素添加了自定义事件触发, 从而正确处理 Remount 发生时的情况
2. [/] 为 Input 元素添加了正确的 onSubmit 事件处理
This commit is contained in:
Minoricew
2025-06-22 22:24:36 +08:00
parent d5b4c4b61e
commit 2ff4a28b70
7 changed files with 66 additions and 15 deletions

View File

@@ -145,9 +145,10 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
inputEl.value = entry.valueGetter();
inputEl.placeholder = entry.placeHolder;
inputEl.id = entry.id;
inputEl.addEventListener("change", async (event) => {
const handleSubmit = async (event = null) => {
const result = await entry.callbackFn(
event.target.value,
event ? event.target.value : inputEl.value,
inputEl,
operationArea,
descriptionArea
@@ -166,7 +167,17 @@ const renderInputArea = (entry, operationArea, descriptionArea) => {
descriptionArea.textContent = result.hint;
descriptionArea.classList.add("ase-desc-error-hint");
}
};
inputEl.addEventListener("change", async (event) => {
await handleSubmit(event);
});
inputEl.onsubmit = async (evt) => {
evt.preventDefault();
await handleSubmit();
};
operationArea.classList.add("ase-operation-area-expanded");
return inputEl;
}