Keep focus on “Hide” while ModalOverlay is visible #795

pull jadijadi wants to merge 1 commits into bitcoin-core:master from jadijadi:gui-weird-focus-fix changing 1 files +10 −0
  1. jadijadi commented at 1:58 pm on February 14, 2024: contributor

    During the initial sync, the Tab moves the focus to the widgets of the main window, even when the ModalOverlay is visible. This creates some weird rectangular selections on the screen.

    This PR fixes this by keeping the focus on the “Hide” button while the ModalOverlay is visible.

    Fixes #783

  2. DrahtBot commented at 1:58 pm on February 14, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK pablomartin4btc
    Concept ACK BrandonOdiwuor
    Stale ACK hebasto

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  3. jadijadi commented at 2:00 pm on February 14, 2024: contributor

    To reproduce the issue (tested on Mac & KDE):

    • open bitcoin gui with wallet
    • Hide the sync modal
    • Go to send tab
    • Highlight the Label
    • Click on the progress bar to open the sync modal
    • press TAB and a misplaced rectangular highlight should appear
  4. hebasto renamed this:
    qt: prevent weird focus rect on inital sync
    Prevent weird focus rect on inital sync
    on Feb 15, 2024
  5. hebasto commented at 10:51 am on February 15, 2024: member
    Why does the issue happen only on certain platforms?
  6. in src/qt/modaloverlay.cpp:64 in e6418e6988 outdated
    58@@ -58,6 +59,10 @@ bool ModalOverlay::eventFilter(QObject * obj, QEvent * ev) {
    59             raise();
    60         }
    61     }
    62+
    63+    if (obj == ui->closeButton && ev->type() == QEvent::FocusOut && layerIsVisible)
    64+        ui->closeButton->setFocus(Qt::OtherFocusReason);
    


    hebasto commented at 10:59 am on February 15, 2024:
    Please use braces.
  7. in src/qt/modaloverlay.cpp:196 in e6418e6988 outdated
    189@@ -185,6 +190,9 @@ void ModalOverlay::showHide(bool hide, bool userRequested)
    190     m_animation.setEndValue(QPoint(0, hide ? height() : 0));
    191     m_animation.start(QAbstractAnimation::KeepWhenStopped);
    192     layerIsVisible = !hide;
    193+
    194+    if (!hide)
    195+        ui->closeButton->setFocus(Qt::OtherFocusReason);
    


    hebasto commented at 10:59 am on February 15, 2024:
    The same.
  8. hebasto commented at 11:00 am on February 15, 2024: member

    … keeping the focus on the “Hide” button while the ModalOverlay is visible.

    That looks like a better commit message / PR description.

  9. jadijadi force-pushed on Feb 15, 2024
  10. jadijadi commented at 11:26 am on February 15, 2024: contributor

    Why does the issue happen only on certain platforms?

    Not sure about other platforms. I had a mac and a KDE machine and happened on both of them. Have not checked on other platforms.

  11. in src/qt/modaloverlay.cpp:195 in 1b34e0deb2 outdated
    190@@ -185,6 +191,10 @@ void ModalOverlay::showHide(bool hide, bool userRequested)
    191     m_animation.setEndValue(QPoint(0, hide ? height() : 0));
    192     m_animation.start(QAbstractAnimation::KeepWhenStopped);
    193     layerIsVisible = !hide;
    194+
    195+    if (!hide) {
    


    hebasto commented at 1:53 pm on February 17, 2024:

    Using the same variable across all conditions for the same action improves readability:

    0    if (layerIsVisible) {
    
  12. hebasto commented at 2:00 pm on February 17, 2024: member

    I can actually see two distinct issues here:

    1. The “Hide” button doesn’t have focus when the overlay shows for the first time. This can be resolved with ui->closeButton->setFocus(); in the ModalOverlay constructor.

    2. The other issue is a bit convoluted. As a child widget, the overlay also follows its parent’s tab order when processing “Tab” or “Shift+Tab” keys. Isolating the overlay’s tab order might also be a solution to the issue.

    This PR indeed forces focus on the “Hide” button as long as the overlay is visible. This approach is acceptable as the “Hide” button is the only one in the overlay.

    Concept and approach ACK 1b34e0deb273bacf0198bb232650b0a324346434. Also tested on Ubuntu 22.04.

  13. hebasto renamed this:
    Prevent weird focus rect on inital sync
    Keep focus on "Hide" while ModalOverlay is visible
    on Feb 17, 2024
  14. hebasto added this to the milestone 27.0 on Feb 17, 2024
  15. qt: keep focus on "Hide" while ModalOverlay is visible
    During the initial sync, the Tab moves the focus to the widgets
    of the main window, even when the ModalOverlay is visible. This
    creates some weird rectangular *selections on the screen*.
    
    This PR fixes this by keeping the focus on the "Hide" button while
    the ModalOverlay is visible.
    
    Fixes #783
    992b1bbd5d
  16. jadijadi force-pushed on Feb 17, 2024
  17. jadijadi commented at 2:24 pm on February 17, 2024: contributor

    I can actually see two distinct issues here:

    1. The “Hide” button doesn’t have focus when the overlay shows for the first time. This can be resolved with ui->closeButton->setFocus(); in the ModalOverlay constructor.
    2. The other issue is a bit convoluted. As a child widget, the overlay also follows its parent’s tab order when processing “Tab” or “Shift+Tab” keys. Isolating the overlay’s tab order might also be a solution to the issue.

    This PR indeed forces focus on the “Hide” button as long as the overlay is visible. This approach is acceptable as the “Hide” button is the only one in the overlay.

    Concept and approach ACK 1b34e0d. Also tested on Ubuntu 22.04.

    Thanks for the ACK. Algo agree with your point on better readability of layerIsVisible. Added that to the commit & squashed.

  18. hebasto commented at 2:55 pm on February 17, 2024: member
  19. luke-jr commented at 10:34 pm on February 20, 2024: member
    Wouldn’t it be better to hide the covered widgets instead?
  20. hebasto removed this from the milestone 27.0 on Mar 4, 2024
  21. hebasto added this to the milestone 28.0 on Mar 4, 2024
  22. hebasto commented at 10:19 am on March 4, 2024: member

    @jadijadi

    Are you still working on this? If so, do you mind addressing #795 (comment)?

  23. jadijadi commented at 1:54 pm on March 4, 2024: contributor

    @jadijadi

    Are you still working on this? If so, do you mind addressing #795 (comment)?

    sorry I have missed that comment. Will check it and come back to you soon.

  24. jadijadi commented at 6:32 am on March 5, 2024: contributor

    Wouldn’t it be better to hide the covered widgets instead?

    Thanks for the suggestion @luke-jr . This is the path I tried first but moved to the current solution because of two issues:

    1. If I used parent()->findChildren<QWidget *>() to find the widgets “behind” this modal and call their hide(), the current modal and its closeButton will be disabled too. To prevent this we have to enable all the direct parents of the closeButton and this needs another loop or a few IMO ugly if (child != ui->closeButton....) clauses.
    2. The above method might interfere with other sourced whom are “hiding” widget in the parent gui and can make future bugs. Imagine this situation: a. an element is disabled on the gui for any reason b. user opens the modal c. I will disable all widgets on the parent (and enable all parents on my CloseButton to enable it) d. user closes the modal e. I enable all widgets on the main window As you can see in this situation the initial state is lost. I have to keep track of the status of all widgets to prevent this.

    Because of these two, I chose the method I implemented but I will be more than happy to hear your comments and update the PR accordingly.

  25. BrandonOdiwuor commented at 11:04 am on March 21, 2024: contributor
    Concept ACK
  26. pablomartin4btc approved
  27. pablomartin4btc commented at 10:15 pm on March 26, 2024: contributor

    Concept & approach ACK 992b1bbd5da95ee782515fb0f5674bb7a02684b2

    Tested this PR on Ubuntu 22.04 with GNOME desktop, not seen any issues with it but I couldn’t reproduce the original issue, perhaps it depends on the platform or it’s KDE’s specific (?).

    I agree with the reasoning on the author’s taken approach, unless there’s another problem that @luke-jr still sees with it.

  28. DrahtBot requested review from hebasto on Mar 26, 2024
  29. DrahtBot requested review from BrandonOdiwuor on Mar 26, 2024
  30. jadijadi commented at 3:53 pm on May 8, 2024: contributor
    Please do not hesitate to ask me if any other update is needed on this from my side. Thanks.
  31. hebasto approved
  32. hebasto commented at 9:43 am on July 15, 2024: member
    re-ACK 992b1bbd5da95ee782515fb0f5674bb7a02684b2
  33. hebasto merged this on Jul 15, 2024
  34. hebasto closed this on Jul 15, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-21 16:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me