Skip to content

Add undo dialog after factory defaults reset from NVDA menu#19575

Merged
seanbudd merged 4 commits into
nvaccess:masterfrom
bramd:fix/reset-config-confirmation-6648
Feb 16, 2026
Merged

Add undo dialog after factory defaults reset from NVDA menu#19575
seanbudd merged 4 commits into
nvaccess:masterfrom
bramd:fix/reset-config-confirmation-6648

Conversation

@bramd

@bramd bramd commented Feb 8, 2026

Copy link
Copy Markdown
Contributor

Link to issue number:

Closes #6648

Summary of the issue:

When users accidentally press the F key in the NVDA menu, configuration is reset to factory defaults with no way to recover. Users may not be able to reconfigure NVDA themselves, and restoring settings can be time-consuming.

Description of user facing changes:

When resetting configuration to factory defaults from the NVDA menu, a dialog is now shown after the reset with "OK" and "Undo" buttons:

  • OK (focused by default): Keeps the factory defaults
  • Undo: Restores the previous configuration
  • Escape: Triggers Undo (restores previous configuration)

This prevents accidental loss of settings. The triple-press keyboard shortcut (NVDA+ctrl+r) is not affected and does not show the dialog, as it is intended for recovery scenarios.

Description of developer facing changes:

  • Added source/gui/configManagement.py with FactoryResetUndoDialog (subclass of MessageDialog) and confirmRevertToDefaultConfiguration
  • Added _confirmRevertToDefaultConfiguration on MainFrame for the menu path, delegating to configManagement
  • onRevertToDefaultConfigurationCommand remains the keyboard shortcut path (no dialog)
  • Both menu and keyboard handlers are decorated with @blockAction.when(blockAction.Context.MODAL_DIALOG_OPEN)

Description of development approach:

The factory reset (core.resetConfiguration(factoryDefaults=True)) only modifies configuration in memory — the on-disk config file is not changed. This means:

  1. Undo simply calls core.resetConfiguration() to reload the saved config from disk
  2. Keep defaults requires no immediate action; the in-memory defaults are saved to disk on normal NVDA shutdown

No file-based backup is needed. This approach was chosen based on community feedback in the issue discussion.

Testing strategy:

  • Unit tests pass
  • Manual testing:
    • Factory reset from menu shows undo dialog
    • Undo restores previous configuration
    • OK keeps factory defaults
    • Triple-press keyboard shortcut works without dialog
    • Escape triggers Undo (restores previous configuration)

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation - Not required
    • Context sensitive help for GUI changes - Not applicable (simple dialog)
  • Testing:
    • Unit tests - Dialog behavior is difficult to unit test; manual testing covers functionality
    • System (end to end) tests - Manual testing covers scenarios
    • Manual testing
  • UX of all users considered:
    • Speech - Dialog is announced, undo confirmation is spoken
    • Braille - Standard dialog, works with braille, auto is the default display and hopefully gives the user braille output
    • Low Vision - Standard Windows dialog
    • Different web browsers - Not applicable
    • Localization in other languages / culture than English - All strings are translatable
  • API is compatible with existing add-ons.
  • Security precautions taken.

@bramd bramd force-pushed the fix/reset-config-confirmation-6648 branch from 4337aca to 52be665 Compare February 8, 2026 15:48
@bramd bramd marked this pull request as ready for review February 8, 2026 15:49
@bramd bramd requested review from a team as code owners February 8, 2026 15:49
Comment thread user_docs/en/changes.md Outdated
Comment thread source/gui/__init__.py Outdated
Comment thread source/gui/__init__.py Outdated
Comment thread source/gui/__init__.py Outdated
Comment thread source/gui/__init__.py Outdated
Comment thread source/gui/__init__.py Outdated
Comment thread source/globalCommands.py Outdated
@bramd

bramd commented Feb 9, 2026

Copy link
Copy Markdown
Contributor Author

@seanbudd I also added a check if backup succeeded before showing the dialog. This will keep the old behavior for some cases, such as running a portable copy from read-only media. I think that is a better experience then showing an undo function which fails silently.

@SaschaCowley SaschaCowley added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Feb 10, 2026
Comment thread source/gui/configManagement.py Outdated
Comment thread source/gui/configManagement.py Outdated
Comment thread source/gui/__init__.py
Comment thread source/gui/configManagement.py Outdated
Comment thread source/gui/configManagement.py Outdated
@seanbudd seanbudd marked this pull request as draft February 13, 2026 05:45
When resetting configuration to factory defaults via the NVDA menu,
a dialog is now shown after the reset with OK and Undo buttons.
This prevents accidental loss of settings when users inadvertently
press F in the NVDA menu. The triple-press keyboard shortcut
(NVDA+ctrl+r) is unaffected as it is intended for recovery scenarios.
* Split the new dialog into a separate file (configManagement.py)
* Reformatted changes entry
* Contain all Undo dialog related code in a new class
…no permission to write to the config location (running portable from read-only media or locked down profile). In that case, undo would silently fail whici is a bad UX.
… undo

Factory reset only modifies config in memory, so undo can simply reload
from disk rather than managing backup files. Also adds blockAction
decorator to onRevertToDefaultConfigurationCommand and fixes copyright.
@bramd bramd force-pushed the fix/reset-config-confirmation-6648 branch from 9e0e7f3 to d87665d Compare February 15, 2026 16:00
@bramd bramd marked this pull request as ready for review February 15, 2026 16:11

@seanbudd seanbudd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @bramd

@seanbudd seanbudd merged commit 225b15a into nvaccess:master Feb 16, 2026
39 of 41 checks passed
@github-actions github-actions Bot added this to the 2026.2 milestone Feb 16, 2026
@CyrilleB79

Copy link
Copy Markdown
Contributor

@bramd, I am just testing this new feature while translating. I found two small issues / points to discuss:

  1. When you press Undo, there should be a message "Factory reset undone. Previous configuration restored.". But this cannot be heard (from my tests). Can you hear it?
  2. Would it be worth setting "Undo" as default button?

@bramd

bramd commented May 14, 2026

Copy link
Copy Markdown
Contributor Author
1. When you press Undo, there should be a message "Factory reset undone. Previous configuration restored.". But this cannot be heard (from my tests). Can you hear it?

Thanks for testing. No, now you mention it, I can't. I think this is because NVDA is in the process of reloading the config. I could either find a way to ensure it's done after the config is reloaded, not sure if that's easy to do from the top of my head or we could remove the message.

2. Would it be worth setting "Undo" as default button?

The idea here was to have OK as the default so you could press enter/space to confirm and esc to undo/cancel. If I set the focus to Undo, there is no quick way to activate OK, besides tabbing to the button and activating it. Even if a user presses OK accidentally, they could return to the saved configuration as usual before exiting NVDA, since that's the point that the config gets saved to disk. However, that's probably not well known/easy to find. Do you think having Undo as the default would be the better behavior? What would you expect esc to do?

@XLTechie

XLTechie commented May 14, 2026 via email

Copy link
Copy Markdown
Collaborator

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

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Reset configuration to factory defaults" would need a confirmation dialog.

5 participants