Bug 433991

Summary: OverlaySheet: Unable to set focus to a component on sheet opened
Product: [Frameworks and Libraries] frameworks-kirigami Reporter: Ismael Asensio <isma.af>
Component: generalAssignee: Marco Martin <notmart>
Status: RESOLVED FIXED    
Severity: normal CC: nate
Priority: NOR Keywords: regression
Version First Reported In: Master   
Target Milestone: Not decided   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed/Implemented In: 5.81
Sentry Crash Report:
Bug Depends on:    
Bug Blocks: 431295    

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