Skip to content

Add validation to prevent empty names in ImageResizer size presets#45425

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-validation-empty-name
Draft

Add validation to prevent empty names in ImageResizer size presets#45425
Copilot wants to merge 3 commits intomainfrom
copilot/add-validation-empty-name

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Summary of the Pull Request

Prevents users from clearing the name field in ImageResizer size preset edit dialog. Empty names made the UI confusing without causing errors.

PR Checklist

  • Communication: I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected
  • Tests: Added/updated and all pass
  • Localization: All end-user-facing strings can be localized
  • Dev docs: Added/updated
  • New binaries: Added on the required places
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Added validation guard in ImageSize.Name property setter:

public string Name
{
    get => _name;
    set
    {
        if (!string.IsNullOrWhiteSpace(value))
        {
            SetProperty(ref _name, value);
        }
    }
}

Invalid assignments (empty, null, whitespace) are silently ignored, preserving the existing value. This matches the existing pattern used for FileName validation in ImageResizerViewModel.

TwoWay binding in UI causes the TextBox to revert when users attempt to clear the field—standard behavior for required fields.

Validation Steps Performed

  • Added unit test ImageSizeNameShouldNotBeSetToEmptyOrNull() covering all rejection and acceptance cases
  • Verified silent rejection behavior matches FileName property pattern

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • i1qvsblobprodcus353.vsblob.vsassets.io
    • Triggering command: /usr/bin/dotnet dotnet build /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/ResultHelper.cs /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Helpers/RegistryHelper.cs /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Enumerations/TruncateSide.cs /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Constants/KeyName.cs /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Constants/MaxTextLength.cs /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/CopyRegistryInfoCommand.cs /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Commands/OpenKeyInEditorCommand.cs /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Re�� /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/CopyType.cs /home/REDACTED/work/PowerToys/PowerToys/src/modules/cmdpal/ext/Microsoft.CmdPal.Ext.Registry/Icons.cs (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[Settings: ImageResizer] Edit size dialog: Add validation against empty name</issue_title>
<issue_description>There is one small thing we should add. (But I don't know how.)
The data in the name field of the edit dialog should be validated against .NullOrEmpty!
Originally posted by @htcfreek in #13285 (comment)

Detailed description:
While users edit an image size in the ImageResizer settings on PT's settings ux they are able to clear the name of the image size. This doesn't lead to errors/exceptions, but it also doesn't make sense to have sizes without a name. So we should prevent user from doing this in the edit dialog.

Note:
This is the second and last change that is needed to prevent the users from having incorrect image size settings (#8698). But I think this is not as relevant, because a missing name won't break image resizing._


cc: @niels9001 </issue_description>

<agent_instructions>Implement a proper fix for this issue. Do NOT create placeholder stub files. Create actual working code that addresses the issue described. Follow PowerToys coding guidelines and conventions.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@TheJoeFin does this issue still happen with v0.73.0? /needinfo

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits February 5, 2026 15:19
Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>
Co-authored-by: yeelam-gordon <73506701+yeelam-gordon@users.noreply.github.com>
Copilot AI changed the title [WIP] Add validation against empty name in image size dialog Add validation to prevent empty names in ImageResizer size presets Feb 5, 2026
Copilot AI requested a review from yeelam-gordon February 5, 2026 15:23
@htcfreek
Copy link
Collaborator

htcfreek commented Feb 5, 2026

@copilot
Can we use text box input validation of winui text box control instead? Does such a feature exist? Because a user feedback would be good to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Settings: ImageResizer] Edit size dialog: Add validation against empty name

3 participants