Skip to content

Fixed toggle switch not working issue.#41049

Merged
yeelam-gordon merged 5 commits intomicrosoft:mainfrom
shuaiyuanxx:shawn/fixSettingsToggleSwitch
Aug 8, 2025
Merged

Fixed toggle switch not working issue.#41049
yeelam-gordon merged 5 commits intomicrosoft:mainfrom
shuaiyuanxx:shawn/fixSettingsToggleSwitch

Conversation

@shuaiyuanxx
Copy link
Contributor

@shuaiyuanxx shuaiyuanxx commented Aug 8, 2025

Summary of the Pull Request

Fixed toggle switch not working issue.

AI Summary

This pull request refactors how DashboardListItem objects are created and added to collections in the DashboardViewModel. The main improvement is to separate the instantiation of each DashboardListItem from the assignment of its EnabledChangedCallback property, which is now set after the object is added to the relevant collection. This change improves clarity and may help prevent issues related to object initialization order.

Refactoring of DashboardListItem creation and initialization:

  • In the AddDashboardListItem method, the DashboardListItem object is now created and added to AllModules before its EnabledChangedCallback property is set, instead of setting this property during object initialization.
  • In the GetShortcutModules method, both ShortcutModules and ActionModules collections now receive DashboardListItem objects that are instantiated first, added to the collection, and then have their EnabledChangedCallback property set. This replaces the previous pattern of setting the callback during object creation. [1] [2]

PR Checklist

Detailed Description of the Pull Request / Additional comments

It is an regression from #40214

Validation Steps Performed

@shuaiyuanxx shuaiyuanxx self-assigned this Aug 8, 2025
@yeelam-gordon yeelam-gordon requested a review from Copilot August 8, 2025 05:05

This comment was marked as outdated.

@yeelam-gordon yeelam-gordon requested a review from Copilot August 8, 2025 05:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a toggle switch functionality issue by reordering the assignment of the EnabledChangedCallback property in two object initializers within the DashboardViewModel class. The callback assignment is moved from before the IsEnabled property to after the DashboardModuleItems property.

Key Changes

  • Moved EnabledChangedCallback assignment to occur after IsEnabled and DashboardModuleItems properties in object initializers

@yeelam-gordon yeelam-gordon added the Product-Settings The standalone PowerToys Settings application label Aug 8, 2025
@yeelam-gordon yeelam-gordon added this to the PowerToys 0.93 milestone Aug 8, 2025
@shuaiyuanxx shuaiyuanxx marked this pull request as ready for review August 8, 2025 05:39
@shuaiyuanxx
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
Signed-off-by: Shuai Yuan <shuai.yuan.zju@gmail.com>
@yeelam-gordon yeelam-gordon force-pushed the shawn/fixSettingsToggleSwitch branch from b5d4e08 to bb1a85c Compare August 8, 2025 14:00
@yeelam-gordon yeelam-gordon merged commit d72e0ab into microsoft:main Aug 8, 2025
10 checks passed
@shuaiyuanxx shuaiyuanxx deleted the shawn/fixSettingsToggleSwitch branch August 11, 2025 01:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Product-Settings The standalone PowerToys Settings application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Settings UI] Some modules cannot be turn off via settings page

2 participants