Skip to content

Conversation

@DinahK-2SO
Copy link
Contributor

@DinahK-2SO DinahK-2SO commented Nov 19, 2025

Description

This is a cherry-pick of PR

For issue

The existing FileTypeChoices property was built on an unordered map, which does not preserve the user-defined order.

However, in the FileOpenPicker and FileSavePicker, the FileTypeChoices need to be displayed in the order they were inserted, rather than in a random order.

This is important for developers' and end-users' experience because:

  • Developers expect to see their file type options in the logical order they added them
  • The first added option is usually the default selection
  • Maintaining consistent ordering helps end users quickly locate the desired file type

Additionaly, the insertion order is respected in the legacy UWP FileSavePicker.

Fix

This is a backward-compatible fix. The goal of this fix is to maintain the existing Map type API contract and its good performance while ensuring that the display order of FileTypeChoices meets expectations.

This pull request refactors the implementation of the FileTypeChoicesMap to ensure that the insertion order of keys is preserved and provides efficient key lookups. It replaces the previous unordered map-based implementation with the implementation backed by a vector. The update also introduces custom iterator and view classes to support this ordered behavior and modifies related tests to verify the new insertion order.

Containment

This PR introduces the following changes for containment:

  • The original FileTypeChoicesMap has been renamed to FileTypeChoicesMapUnordered.
  • A new FileTypeChoicesMap with the fix applied has been added.
  • The behavior is controlled by the Feature_StoragePickersChoicesInsertionOrder velocity flag:
    • When enabled: FileSavePicker uses the updated FileTypeChoicesMap with the fix.
    • When disabled: FileSavePicker uses the original FileTypeChoicesMapUnordered.
…ion order (#5948) **Description** This is a fix for issue: - #5827 The existing FileTypeChoices property was built on an unordered map, which does not preserve the user-defined order. However, in the FileOpenPicker and FileSavePicker, the FileTypeChoices need to be displayed in the order they were inserted, rather than in a random order. This is important for developers' and end-users' experience because: - Developers expect to see their file type options in the logical order they added them - The first added option is usually the default selection - Maintaining consistent ordering helps end users quickly locate the desired file type Additionaly, the insertion order is respected in the legacy UWP FileSavePicker. **Fix** This is a backward-compatible fix. The goal of this fix is to maintain the existing Map type API contract and its good performance while ensuring that the display order of FileTypeChoices meets expectations. This pull request refactors the implementation of the `FileTypeChoicesMap` to ensure that the insertion order of keys is preserved and provides efficient key lookups. It replaces the previous unordered map-based implementation with the implementation backed by a vector. The update also introduces custom iterator and view classes to support this ordered behavior and modifies related tests to verify the new insertion order.
@DinahK-2SO DinahK-2SO force-pushed the user/DinahK-2SO/cherry-pick-ordered-filetypechoices branch from e0613c2 to c7be002 Compare November 19, 2025 08:20
@DinahK-2SO DinahK-2SO force-pushed the user/DinahK-2SO/cherry-pick-ordered-filetypechoices branch from 3dc103a to 5c3bab8 Compare November 19, 2025 16:59
@DinahK-2SO DinahK-2SO changed the title [CP to 1.8] Cherry-pick Fix FileTypeChoices in Storage Pickers to preserve insertion order (#5948) [CP to 1.8] Cherry-pick Fix FileTypeChoices in Storage Pickers to preserve insertion order Nov 20, 2025
Copy link
Collaborator

@codendone codendone left a comment

Choose a reason for hiding this comment

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

@DinahK-2SO
Copy link
Contributor Author

Thanks @codendone for sharing the example! I updated the containment.

@DinahK-2SO
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@DinahK-2SO DinahK-2SO enabled auto-merge (squash) November 21, 2025 16:55
@DinahK-2SO
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).
@DinahK-2SO DinahK-2SO added area-File access Topics related to Microsoft.Windows.Storage.Pickers APIs for selecting files/folders etc. and removed needs-triage labels Nov 22, 2025
@DinahK-2SO DinahK-2SO merged commit a7b0e6b into release/1.8-stable Nov 24, 2025
36 checks passed
@DinahK-2SO DinahK-2SO deleted the user/DinahK-2SO/cherry-pick-ordered-filetypechoices branch November 24, 2025 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-File access Topics related to Microsoft.Windows.Storage.Pickers APIs for selecting files/folders etc.

3 participants