Skip to content
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

Workaround focus leaving input box on consecutive submissions #15479

Merged
merged 5 commits into from Dec 13, 2023

Conversation

krassowski
Copy link
Member

@krassowski krassowski commented Dec 2, 2023

References

Fixes #12322

Code changes

  • immediately after submission the input box will:
    • become soft-invisible (opacity + height) to keep it hidden but focused
    • reject any key events (but will not be disabled to keep focus)
  • the input box will be detached after 0.5s delay

In the first commit I was trying to use :has() but gave up on this due to lack of FF support (and the support behind flag failing on this use case, reported in https://bugzilla.mozilla.org/show_bug.cgi?id=1867893).

User-facing changes

Users will be able to quickly send replies without the input box loosing focus and leading to the code editor being overwritten.

This is 99% solution - if the delay is over 0.5s it will fail.

Backwards-incompatible changes

None

Tested that it fails on main reproducing the issue:

```
    - Expected  - 0
    + Received  + 8

      from time import sleep
      input()
      print('before sleep')
      sleep(0.1)
      print('after sleep')
    +
    +
    + x
    +
    +
    +
    +
    +
```
https://bugzilla.mozilla.org/show_bug.cgi?id=1867893

`:has()` is not only not yet officially supported but is hard to
implement well so no wonder there are difficult invalidation bugs
@krassowski krassowski added the bug label Dec 2, 2023
@krassowski krassowski added this to the 4.0.x milestone Dec 2, 2023
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@github-actions github-actions bot added pkg:outputarea tag:Testing tag:CSS For general CSS related issues and pecadilloes Design System CSS labels Dec 2, 2023
Copy link
Member

@jtpio jtpio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@krassowski krassowski merged commit 68be103 into jupyterlab:main Dec 13, 2023
77 of 79 checks passed
@krassowski
Copy link
Member Author

@meeseeksdev please backport to 4.0.x

Copy link

lumberbot-app bot commented Dec 13, 2023

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 4.0.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 68be1035baf991546e9436bf9a5c7493266568c2
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #15479: Workaround/input box focus'
  1. Push to a named branch:
git push YOURFORK 4.0.x:auto-backport-of-pr-15479-on-4.0.x
  1. Create a PR against branch 4.0.x, I would have named this PR:

"Backport PR #15479 on branch 4.0.x (Workaround/input box focus)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@krassowski krassowski changed the title Workaround/input box focus Workaround focus leaving input box on consecutive submissions Dec 13, 2023
krassowski added a commit to krassowski/jupyterlab that referenced this pull request Dec 26, 2023
* Re-focus input after modifying model, keep input for 0.5s

* Add a test case against the focus loss issue

Tested that it fails on main reproducing the issue:

```
    - Expected  - 0
    + Received  + 8

      from time import sleep
      input()
      print('before sleep')
      sleep(0.1)
      print('after sleep')
    +
    +
    + x
    +
    +
    +
    +
    +
```

* Give up on using animations and :has() solution due to FF bug

https://bugzilla.mozilla.org/show_bug.cgi?id=1867893

`:has()` is not only not yet officially supported but is hard to
implement well so no wonder there are difficult invalidation bugs

* More robust stdin test

(cherry picked from commit 68be103)
krassowski added a commit that referenced this pull request Dec 27, 2023
* Re-focus input after modifying model, keep input for 0.5s

* Add a test case against the focus loss issue

Tested that it fails on main reproducing the issue:

```
    - Expected  - 0
    + Received  + 8

      from time import sleep
      input()
      print('before sleep')
      sleep(0.1)
      print('after sleep')
    +
    +
    + x
    +
    +
    +
    +
    +
```

* Give up on using animations and :has() solution due to FF bug

https://bugzilla.mozilla.org/show_bug.cgi?id=1867893

`:has()` is not only not yet officially supported but is hard to
implement well so no wonder there are difficult invalidation bugs

* More robust stdin test

(cherry picked from commit 68be103)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Design System CSS pkg:outputarea tag:CSS For general CSS related issues and pecadilloes tag:Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ipdb focus issues causes some characters to be put into cell above
2 participants