[CP to 1.8] Cherry-pick Fix FileTypeChoices in Storage Pickers to preserve insertion order #6018
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
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:
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
FileTypeChoicesMapto 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:
FileTypeChoicesMaphas been renamed toFileTypeChoicesMapUnordered.FileTypeChoicesMapwith the fix applied has been added.Feature_StoragePickersChoicesInsertionOrdervelocity flag:FileSavePickeruses the updatedFileTypeChoicesMapwith the fix.FileSavePickeruses the originalFileTypeChoicesMapUnordered.