Skip to content

Commit 9f4214a

Browse files
committed
fix: enforce baseLayer focus when launcher becomes visible
To address the low-probability issue where the launcher loses keyboard focus upon opening (preventing direct text input), this commit explicitly calls forceActiveFocus() on the baseLayer (InputEventItem) when LauncherController.visible becomes true. Unlike previous attempts that focused the searchEdit directly (which violated the design requirement of not activating the search bar visually upon open), this approach ensures the root item safely receives key events and forwards them to the search edit without triggering unwanted visual states. 修复启动器以极低概率打开时丢失键盘焦点(无法直接输入文本)的问题。 在启动器显示(LauncherController.visible 为 true)时,显式调用 baseLayer (InputEventItem) 的 forceActiveFocus() 强制获取活跃焦点。 与之前直接聚焦 searchEdit 的尝试(违背了打开时不直接激活搜索框 的设计要求)不同,此方法确保根节点能安全地接收按键事件并将其转发 给搜索框,同时不会触发不需要的视觉激活状态。 PMS: BUG-301743
1 parent c5982f0 commit 9f4214a

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

qml/FullscreenFrame.qml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -887,8 +887,13 @@ InputEventItem {
887887
Connections {
888888
target: LauncherController
889889
function onVisibleChanged() {
890-
// only do these clean-up steps on launcher get hide
891-
if (LauncherController.visible) return
890+
if (LauncherController.visible) {
891+
baseLayer.forceActiveFocus()
892+
if (!baseLayer.activeFocus) {
893+
console.warn("[LaunchpadFocus] FullscreenFrame: BUG_WARNING - baseLayer failed to acquire activeFocus immediately after forceActiveFocus()!")
894+
}
895+
return
896+
}
892897
// clear searchEdit text
893898
searchEdit.text = ""
894899
if (listviewPage.currentItem) {

qml/windowed/WindowedFrame.qml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,13 @@ InputEventItem {
305305
Connections {
306306
target: LauncherController
307307
function onVisibleChanged() {
308-
// only do these clean-up steps on launcher get hide
309-
if (LauncherController.visible) return
308+
if (LauncherController.visible) {
309+
baseLayer.forceActiveFocus()
310+
if (!baseLayer.activeFocus) {
311+
console.warn("[LaunchpadFocus] WindowedFrame: BUG_WARNING - baseLayer failed to acquire activeFocus immediately after forceActiveFocus()!")
312+
}
313+
return
314+
}
310315

311316
// clear searchEdit text
312317
bottomBar.searchEdit.text = ""

0 commit comments

Comments
 (0)