PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

[Settings > PT Run > PluginAdditionalOptions] Fix crash on empty number box

Open htcfreek opened this issue 1 year ago • 1 comments

Summary of the Pull Request

The settings app crashes when the user clears the number box and presses enter or moves the focus away from it. This happens because the value is not a valid number and converting this to double produces double.NaN. The double.NaN then leads to the app crash.

To fix this we now check the value of the number box against NaN and if the check is true we send a NotifyPropertyChanged() command. This lets the NumberBox reload its binding value and resets the NumberBox to the last valid number input.

We should consider this PR in a HotFix if we need one after releasing v0.81.0!

PR Checklist

  • [x] Closes: #32738
  • [x] Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • [x] 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

Validation Steps Performed

htcfreek avatar May 12 '24 08:05 htcfreek

@check-spelling-bot Report

:red_circle: Please review

See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.

Unrecognized words (5)

awai convertet experienece firendly setiings

Previously acknowledged words that are now absent COMMANDTITLE FILELOCKSMITHLIB gdnbaselines interactable JArray ksh localport OOBEPT Pathto qwertyuiopasdfghjklzxcvbnm qwrtyuiopsghjklzxvnm redirectedfrom runsettings testhost toggleswitch 🫥
To accept these unrecognized words as correct and remove the previously acknowledged and now absent words, you could run the following commands

... in a clone of the [email protected]:htcfreek/PowerToys.git repository on the PT_RunSettingsFix branch (:information_source: how do I use this?):

curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/v0.0.22/apply.pl' |
perl - 'https://github.com/microsoft/PowerToys/actions/runs/9050167953/attempts/1'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary

This includes both expected items (1876) from .github/actions/spell-check/expect.txt and unrecognized words (5)

Dictionary Entries Covers Uniquely
cspell:r/src/r.txt 543 1 1
cspell:cpp/src/people.txt 23 1
cspell:cpp/src/ecosystem.txt 51 1

Consider adding them (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

      with:
        extra_dictionaries:
          cspell:r/src/r.txt
          cspell:cpp/src/people.txt
          cspell:cpp/src/ecosystem.txt

To stop checking additional dictionaries, add (in .github/workflows/spelling2.yml) for uses: check-spelling/[email protected] in its with:

check_extra_dictionaries: ''
If the flagged items are :exploding_head: false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it, try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

github-actions[bot] avatar May 12 '24 08:05 github-actions[bot]

"severity high" + "wait for 0.82" ?

Jay-o-Way avatar May 13 '24 15:05 Jay-o-Way

"severity high" + "wait for 0.82" ?

Issue has "Severity highd".

@jaimecbernardo marked other PRs last week with "wait for 0.82". So I thought the time frame for 0.81 is closed. @jaimecbernardo, is it closed?

htcfreek avatar May 13 '24 15:05 htcfreek

"severity high" + "wait for 0.82" ?

Issue has "Severity highd".

@jaimecbernardo marked other PRs last week with "wait for 0.82". So I thought the time frame for 0.81 is closed. @jaimecbernardo, is it closed?

We can still get some simpler ones in. This one I think can go in. We're waiting for "Patch Tuesday" tomorrow to receive latest .NET and only after that build the release candidate, so this can still get in.

Help me out understand something: this doesn't affect any current PowerToys Run plugin, right? I don't think we're using this NumberBox one ourselves, or are we? @htcfreek

jaimecbernardo avatar May 13 '24 15:05 jaimecbernardo

@jaimecbernardo

  1. We don't use it in any of our built-in plugins.
  2. This has no impacts on any configuration files or plugin code. It only improves the value handling in the PluginOption ViewModel of the PT Run Settings page.
  3. It simply resets empty input to the last know valid value.

htcfreek avatar May 13 '24 15:05 htcfreek