Reset textbox value to empty string when value is None (#5114)

* reset value to empty string when null

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Hannah 2023-08-08 20:53:57 +02:00 committed by GitHub
parent 61129052ed
commit 56d2609de9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -0,0 +1,6 @@
---
"@gradio/textbox": patch
"gradio": patch
---
fix:Reset textbox value to empty string when value is None

View File

@ -28,6 +28,8 @@
$: value, el && lines !== max_lines && resize({ target: el });
$: if (value === null) value = "";
const dispatch = createEventDispatcher<{
change: string;
submit: undefined;
@ -70,7 +72,7 @@
const text = target.value;
const index: [number, number] = [
target.selectionStart as number,
target.selectionEnd as number
target.selectionEnd as number,
];
dispatch("select", { value: text.substring(...index), index: index });
}
@ -132,7 +134,7 @@
resize({ target: _el });
return {
destroy: () => _el.removeEventListener("input", resize)
destroy: () => _el.removeEventListener("input", resize),
};
}
</script>