-
Notifications
You must be signed in to change notification settings - Fork 55
fix: Fix the focus issue on secondary pages in Quick Settings #1355
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
Conversation
Fix the focus issue on secondary pages in Quick Settings Log: Fix the focus issue on secondary pages in Quick Settings pms: BUG-341435
deepin pr auto review我来对这段代码变更进行审查:
function takeFocus() {
if (impl) {
impl.takeFocus()
}
}改进建议:
总体来说,这是一个合理的代码变更,实现了焦点管理的功能,但可以通过添加错误处理和注释来提高代码质量。 |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR fixes a focus handling bug on secondary Quick Settings pages by adding explicit focus delegation functions and invoking them when pages become active in the StackView. Sequence diagram for focus delegation on Quick Settings secondary pagessequenceDiagram
actor User
participant QuickPanelPage
participant StackView
participant SubPluginPage
participant ShellSurfaceItemProxy as SurfaceLayer
participant ShellSurfaceItemImpl as ShellSurfaceItem
User->>QuickPanelPage: select_secondary_quick_setting()
QuickPanelPage->>StackView: push(SubPluginPage)
StackView->>SubPluginPage: activate()
note over StackView,SubPluginPage: StackView.onActivated triggers
StackView->>SubPluginPage: takeFocus()
SubPluginPage->>SurfaceLayer: takeFocus()
SurfaceLayer->>ShellSurfaceItem: takeFocus()
ShellSurfaceItem-->>SurfaceLayer: focus_set()
SurfaceLayer-->>SubPluginPage: focus_confirmed()
SubPluginPage-->>User: secondary_page_is_focused()
Updated class diagram for Quick Settings focus handling componentsclassDiagram
class ShellSurfaceItemProxy {
+int implicitWidth
+int implicitHeight
+ShellSurfaceItem impl
+takeFocus()
}
class ShellSurfaceItem {
+int width
+int height
+takeFocus()
}
ShellSurfaceItemProxy *-- ShellSurfaceItem : contains_impl
class SubPluginPage {
+int subPluginMinHeight
+int headerMargin
+Item surfaceLayer
+takeFocus()
}
SubPluginPage *-- ShellSurfaceItemProxy : uses_as_surfaceLayer
class QuickPanelPage {
+int contentHeight
+Item panelView
+StackView stackView
}
class StackView {
+onActivating()
+onActivated()
+push(page)
}
QuickPanelPage *-- StackView : contains
StackView --> SubPluginPage : manages_pages
class FocusFlow {
+takeFocus()
}
FocusFlow <|.. ShellSurfaceItemProxy : focus_delegate
FocusFlow <|.. SubPluginPage : focus_delegate
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and found some issues that need to be addressed.
- In QuickPanelPage.qml,
StackView.onActivatedblindly callstakeFocus(), which will throw if a given page/delegate does not implement that function; consider checking for its existence (e.g.,if (typeof takeFocus === 'function') takeFocus();) or using a more generic focus API. - In SubPluginPage.qml and ShellSurfaceItemProxy.qml, the new
takeFocus()helpers assumesurfaceLayer/implalways exist and exposetakeFocus; adding null/feature checks would make this safer against future layout or component changes.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In QuickPanelPage.qml, `StackView.onActivated` blindly calls `takeFocus()`, which will throw if a given page/delegate does not implement that function; consider checking for its existence (e.g., `if (typeof takeFocus === 'function') takeFocus();`) or using a more generic focus API.
- In SubPluginPage.qml and ShellSurfaceItemProxy.qml, the new `takeFocus()` helpers assume `surfaceLayer`/`impl` always exist and expose `takeFocus`; adding null/feature checks would make this safer against future layout or component changes.
## Individual Comments
### Comment 1
<location> `panels/dock/tray/quickpanel/QuickPanelPage.qml:67-68` </location>
<code_context>
StackView.onActivating: function () {
panelView.contentHeight = Qt.binding(function() { return contentHeight})
}
+ StackView.onActivated: function () {
+ takeFocus()
+ }
}
</code_context>
<issue_to_address>
**issue (bug_risk):** Unqualified `takeFocus()` here is likely calling the wrong (or a non-existent) function.
Within this `StackView.onActivated` handler, `takeFocus()` will be resolved through the JS scope chain rather than on the activated item. If the goal is to focus the newly activated page, call it explicitly on that item (for example, `currentItem && currentItem.takeFocus()`) or another clearly scoped reference. As written, it may either invoke an unintended function or fail at runtime if `takeFocus` is not defined in the current scope.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Fix the focus issue on secondary pages in Quick Settings
Log: Fix the focus issue on secondary pages in Quick Settings
pms: BUG-341435
Summary by Sourcery
Fix focus handling in Quick Settings pages to ensure the active view correctly receives focus when navigated to.
Bug Fixes: