Bug 433991 - OverlaySheet: Unable to set focus to a component on sheet opened
Summary: OverlaySheet: Unable to set focus to a component on sheet opened
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kirigami
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: Master
Platform: Other Other
: NOR normal
Target Milestone: Not decided
Assignee: Marco Martin
URL:
Keywords: regression
Depends on:
Blocks: 431295
  Show dependency treegraph
 
Reported: 2021-03-05 09:06 UTC by Ismael Asensio
Modified: 2021-03-09 15:46 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.81
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ismael Asensio 2021-03-05 09:06:55 UTC
SUMMARY

This was introduced on  https://invent.kde.org/frameworks/kirigami/-/merge_requests/143.

To make the Esc capture work, currently the focus has to be forced to the Overlay Sheet item. This happens after signal `onSheetOpenChanged` has been raised, so it overrides any previous focus the user code may have set also on this signal. Or at best there would be a race condition.

TEST CASE PSEUDOCODE (cannot test it right now)

Kirigami.OverlaySheet {

   onSheetOpenChanged: {
       if (sheetOpen) {
           myText.forceActiveFocus()  // will be overriden
       }
   }

   QQC2.TextField {
       id: myText
   }
}


OBSERVED RESULT
The internal Item does not gain focus

EXPECTED RESULT
The internal Item should gain focus
Comment 1 Bug Janitor Service 2021-03-05 18:30:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kirigami/-/merge_requests/250
Comment 2 Marco Martin 2021-03-09 14:29:51 UTC
Git commit 0f2c4005715be3c0d61ab6c64e79ef742420e53e by Marco Martin.
Committed on 09/03/2021 at 14:29.
Pushed by mart into branch 'master'.

turn contentItemParent into a FocusScope

when forcing it to active focus, it should not steal the focus
from any of its descendants, and a focusScope will have focus
whenever any descendant has it, and won't ever steal it from them

M  +1    -1    src/controls/templates/OverlaySheet.qml

https://invent.kde.org/frameworks/kirigami/commit/0f2c4005715be3c0d61ab6c64e79ef742420e53e