Skip to content

Commit 44265b0

Browse files
authored
Fix native select and change event capture for json_editor element. (#4458)
The `svelte-jsoneditor` library seems to have some native events which utilize the `select` and `change` naming. This causes exceptions once these reach the `NiceGUI` event handlers without expected arguments. This PR changes these names to remove the conflict. Per issue #4397.
1 parent 6f69985 commit 44265b0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

nicegui/elements/json_editor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ export default {
44
template: "<div></div>",
55
mounted() {
66
this.properties.onChange = (updatedContent, previousContent, { contentErrors, patchResult }) => {
7-
this.$emit("change", { content: updatedContent, errors: contentErrors });
7+
this.$emit("content_change", { content: updatedContent, errors: contentErrors });
88
};
99
this.properties.onSelect = (selection) => {
10-
this.$emit("select", { selection: selection });
10+
this.$emit("content_select", { selection: selection });
1111
};
1212

1313
this.checkValidation();

nicegui/elements/json_editor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ def on_change(self, callback: Handler[JsonEditorChangeEventArguments]) -> Self:
4848
"""Add a callback to be invoked when the content changes."""
4949
def handle_on_change(e: GenericEventArguments) -> None:
5050
handle_event(callback, JsonEditorChangeEventArguments(sender=self, client=self.client, **e.args))
51-
self.on('change', handle_on_change, ['content', 'errors'])
51+
self.on('content_change', handle_on_change, ['content', 'errors'])
5252
return self
5353

5454
def on_select(self, callback: Handler[JsonEditorSelectEventArguments]) -> Self:
5555
"""Add a callback to be invoked when some of the content has been selected."""
5656
def handle_on_select(e: GenericEventArguments) -> None:
5757
handle_event(callback, JsonEditorSelectEventArguments(sender=self, client=self.client, **e.args))
58-
self.on('select', handle_on_select, ['selection'])
58+
self.on('content_select', handle_on_select, ['selection'])
5959
return self
6060

6161
@property

0 commit comments

Comments
 (0)