-
Notifications
You must be signed in to change notification settings - Fork 89
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
Editor loses focus if data is changed and displayed #15
Comments
Hi! Can u please use this link and check if this behaviour happens? https://stackblitz.com/edit/angular-json-editor?file=src%2Fapp%2Fapp.component.ts |
Sure, I forked your example and added the assignment: https://stackblitz.com/edit/angular-json-editor-uodqc5 And just to make sure that we are talking about the same thing: I am fully aware that it is impossible to automatically do much about the changing data itself: If the bound data changes there may be any number of conflicts that can't be resolved automatically. I do not expect any meaningful cursor position or expansion state if the bound data changes randomly! This is basically the same scenario a text editor is in when it detects that the edited file has changed on disk. And it resolves that by asking the user what to do: "Keep the state from the editor" or "Reload from disk"? Imho this kind of logic is far outside the scope of this neat little wrapper. But maybe it would be possible to somehow preserve some state like the previous position of the cursor and the selected mode? At least for minor edits this should do the trick. |
Gotcha! My question is.. why you need to change the data? If you need to save this on database, just call the ajax, or if you need that in another component, you can call a event or service to pass it on Because the problem here is to update the same data you used to build the jsoneditor |
Thanks!! I think i got a solution for you, check version 1.6.2.. if is not working as expected please reopen |
I would like to reflect changes on the fly (e.g. as soon as the user changes something). But every time I change something in the
code
or thetree
view, the jsoneditor loses focus. This issue can be replicated in the sample code by addingthis.data = JSON.parse(this.editor.getText())
in thechange
-callback.I suspect this happens because Angular re-renders the view and destroys the jsoneditor in that process. But would there be any way to work around this?
Edit (after further investigation): Its far more then the editing state that is lost on changes. The previously selected mode is lost as well and the current expansion state is lost as well. It seems that the editor is resetted entirely .
The text was updated successfully, but these errors were encountered: