Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SelectionOrder DataAdapter decorator and related options #6014

Closed

Commits on Mar 31, 2021

  1. Add SelectionOrder DataAdapter decorator and related options as a p…

    …roposal to resolve select2#3106 with some limitations for manual selection changes (as noted).
    
    - This class has to keep both display and selection ordering for all options in order to manage selection order, while maintaining the default results/query ordering (when `sorter` is not used, etc).
    - Notable but unfortunate limitation: Setting the control value using `jQuery.val([...])` with multiple items or manually toggling option `selected` (without a `change` event) still cannot preserve the value ordering.
      - The partial workaround for this is to manually set your selected options with the `data-selection-order` attribute before setting val() if possible.
      - It may also be possible to enhance the decorator to watch for manual changes via MutationObserver. TBD.
    
    New options:
    - `keepSelectionOrder`
    - `trackManualSelectionOrder`
    
    Update docs.
    Add tests.
    devmonkey22 committed Mar 31, 2021
    Copy the full SHA
    5fbd45f View commit details
    Browse the repository at this point in the history

Commits on Apr 5, 2021

  1. SelectionOrder decorator changes:

    - Refactor initial DOM option and change event processing.
    - Refactor option item/data to hold displayOrder/selectionOrder values, and inspect DOM attributes as way to manually set/update as needed (ie: when adding options, setting values, etc).
    - Fix issues with using `ArrayData` and subclasses like `AjaxData`.
    
    SelectAdapter fix:
    - Update `SelectAdapter.prototype._normalizeItem` to properly set `id` from `text` for `<option>Text</option>` (no `value`) scenarios. This allows finding these options by value/id properly.
    
    Update CHANGELOG.md with `SelectionOrder` decorator changes.
    devmonkey22 committed Apr 5, 2021
    Copy the full SHA
    afd3a19 View commit details
    Browse the repository at this point in the history