-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Setting form editor has a formState to avoid focus lost #12470
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
Setting form editor has a formState to avoid focus lost #12470
Conversation
|
Thanks for making a pull request to jupyterlab! |
| super(props); | ||
| const { settings } = props; | ||
| this.state = { | ||
| this.formState = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The formData pass to Form is indeed only the initial value. So it makes sense to extract formData from the state. However isModified should be kept in the state otherwise the Restore to Defaults button does not appear when needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting back isModified in the react state generate rendering and looses the focus (the Restore to Defaults button is show again).
I have tried alternative approaches #12160 (comment) without success.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened datalayer-externals#3 with a better approach that only update props appropriately avoiding unnecessary component rerendering that were creating the focus lost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. I have merged your changes. Thx a bunch for this.
…-lost Better handling of derived props computation
fcollonval
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @echarles
|
@meeseeksdev please backport to 3.4.x |
…avoid focus lost
|
Thx @fcollonval for the reviews and helps. I have merged and the backport to 3.4.x is available on #12490 |
|
@fcollonval I am now testing master branch with this merge, and I face an issue. The settings editor does not open anymore (the json editor does). I wonder how this is related to #12485 As mentioned on that issue, I faced the problem once those last days, but today it is 100% reproducible. It looks like this code block is responsible for the UI not showing up. If I comment-out the block the editor is shown correctly (with the focus being not lost, which is good). If I refresh the page, the editor opens back again. |
…s lost (#12490) Co-authored-by: Eric Charles <eric@datalayer.io>
Benchmark reportThe execution time (in milliseconds) are grouped by test file, test type and browser. The mean relative comparison is computed with 95% confidence. Results table
Changes are computed with expected as reference. |
References
Fixes #12160
Code changes
Use a dedicated class field to maintain the form state instead of the standard react state. This avoid rerendering and focus lost.
User-facing changes
Focus is no more lost.
Backwards-incompatible changes
None.