Skip to content
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

ColorDialog fails to reset Custom Colors collection after clicking Cancel #13067

Closed
Syareel-Sukeri opened this issue Mar 4, 2025 · 0 comments · Fixed by #13080
Closed

ColorDialog fails to reset Custom Colors collection after clicking Cancel #13067

Syareel-Sukeri opened this issue Mar 4, 2025 · 0 comments · Fixed by #13080
Assignees
Labels
🚧 work in progress Work that is current in progress

Comments

@Syareel-Sukeri
Copy link
Contributor

Syareel-Sukeri commented Mar 4, 2025

.NET version

.NET 10.0 SDK build: 10.0.100-preview.3.25153.9

Did it work in .NET Framework?

Yes

Did it work in any of the earlier releases of .NET Core or .NET 5+?

No, still repro in .NET 8.0/9.0

Issue description

Current Behavior (.NET Core):
The Custom Colors collection is not cleared after clicking Cancel.

ColorDialogCore.mp4

Expected Behavior (.NET Framework):
The Custom Colors collection reset after clicking Cancel.

ColorDialogFx.mp4

Steps to reproduce

  1. Create a WinForms project in .NET Core with Button and ColorDialog added.
  2. In the button’s click event, show the ColorDialog:
    private void button1_Click(object sender, EventArgs e)
    {
      colorDialog1.ShowDialog();
    }
  1. Run the application and click the button to open the ColorDialog.
  2. Add a custom color and click Cancel.
  3. Click the button again to reopen the ColorDialog.

or using following sample app

ColorDialogCC.zip

More Info

  1. The issue cannot be reproduced when a new ColorDialog is created inside the method each time. In this case, the Custom Colors reset correctly after reopening the dialog in both .NET Core and .NET Framework.
private void button1_Click(object sender, EventArgs e)
{
    using (ColorDialog colorDialog = new ColorDialog())
    {
        colorDialog.ShowDialog();
    }
}
@Syareel-Sukeri Syareel-Sukeri added the untriaged The team needs to look at this issue in the next triage label Mar 4, 2025
@JeremyKuhne JeremyKuhne self-assigned this Mar 4, 2025
@JeremyKuhne JeremyKuhne removed the untriaged The team needs to look at this issue in the next triage label Mar 4, 2025
JeremyKuhne added a commit to JeremyKuhne/winforms that referenced this issue Mar 5, 2025
This regressed when moving to CsWin32. We need to use a copy of custom colors when calling ChooseColor so that we can skip updating colors when the dialog is cancelled.

Fixes dotnet#13067
@dotnet-policy-service dotnet-policy-service bot added the 🚧 work in progress Work that is current in progress label Mar 5, 2025
JeremyKuhne added a commit that referenced this issue Mar 6, 2025
This regressed when moving to CsWin32. We need to use a copy of custom
colors when calling ChooseColor so that we can skip updating colors when
the dialog is cancelled.

Fixes #13067
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚧 work in progress Work that is current in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants