When the dropdown is in the dropdown that is attached to the body,
the call to `show` causes `display: inline` to be set directly on
the search container. This causes rendering issues, so this change
uses a class instead of calling `show` and `hide` directly.
This is most likely a jQuery bug of some form, as it only happens
when using the dropdown that is attached to the body.
In Select2 3.x, the dropdown is attached to the body element and
it is floated above all other elements.
In Select2 4.x, the dropdown is attached directly to the Select2
container, which allows us to skip any special placing logic. This
happens to be how Chosen currently does it, and it prevents us
from having the dropdown display up, as well as a few other strange
issues that can't be prevented.
This new module will most likely become the default, as it matches
the functionality of Select2 3.x and has quite a few advantages.
The other positioning code will need to be broken out into a
separate module in the future.
The main container should not need to position the individual
components. This makes it easier for components to override where
they should be placed, such as adding the dropdown outside of the
container.
When destroying Select2, an error could be raised while destroying
the selection container. This was because the destroy handler was
relying on the container id being present.
The old functionality has been restored where Select2 will destroy
itself when it is initialized again.
This is inspired by https://github.com/ivaynberg/select2/issues/2826
and starts the general transition to using selectors with a lower
specificity. This should make it considerably easier to override
the styles in the long run.
Unfortunately libsass does not support the SASS 3.3 style for BEM
where we can just use `&__m` for defining sub-modules. For now we
are still using a limited amount of nesting, but nowhere near as
much as we did in the past.
Now the search box is automatically resized for placeholders to
fit the available space, so we don't need to worry about the
placeholder not being visible. When the placeholder doesn't need
to be visible, the size of the search box is determined based on
the length of the current search term.
This adds a search box to the main container for multiple select
boxes, similar to the what the old version had. This can still be
swapped out such that the search box displays above the results
like it previously did.
The placeholder for multiple selects will also now use the input
attribute of the search box instead of generating a custom element.
This also changes the selector for the search container to
`.select2-search`, which is consistent with the old class and
reduces the complexity of the selectors.
This fixes an issue with how decorators worked, where the constructor
from the parent class would clobber the custom constructor that is
generated for the new decorated class. This has been fixed by
excluding the constructor from the list of fields which are
transferred when decorating classes.
This adds a dictionary for converting diacritics to a normalized
representation. This dictionary is used in the default matcher.
The code for stripping the diacritics was pulled from the current
implementation in Select2 3.x.
This migrates over the required English translations under their
new names.
The "Searching" message has also been adjusted to use "Searching..."
instead of "Loading more results...", which is what it used to
say sometimes.
This also changes the AJAX handler to call `abort` when needed.
Now when searching, a loading message is prepended to the top of
the results. This replaces the old spinner image and allows for it
to be translated across different languages.
The loading message can be styled differently and is passed
through the results formatters.
Previously, a result was no longer highlighted when the mouse was
no longer over it. While this was useful for resetting the
highlight automatically, we started doing this when a new result
was highlighted to make sure that we never had multiple options
highlighted.
Now, a result will always be highlighted until the highlight is
removed when the next result is highlighted. While this shouldn't
affect many users, it is closer to how native select boxes work.
This also allows users using keyboard navigation to jump between
mouse and keyboard navigation without the highlight reseting to
the top of the results.
This fixes many of the speed issues the results had when working
with large data sets. jQuery has been completely dropped, with the
exception of setting the data, which does not require a jQuery
object but instead works directly with the DOM. This does not
include options with children, which still uses jQuery to deal
with the nested objects.
This only works with IE 8+, which is fine.
This fixes caching when querying, so the data object no longer
needs to be completely regenerated whenever the `<option>` is
queried.
While this does not fix the speed issues on the first opening of
the instance, it does fix the speed issues during searching.
This improves the speeds of creating the `<option>` tags for array
data. By creating the HTML ahead of time and putting it into an
`<option>` element before passing it to jQuery, it cuts down on the
time it takes for jQuery to process the HTML string and convert it
into DOM elements. This proved to be incredibly slow.
This also changes the `item` function to return early when the
data exists. The `$e.data` call has also been switched to a
`$.data` call, which doesn't need to check the DOM to see if the
data attributes already exist. This cuts down on a bit of wasted
time, as the `data` key should never be present in the DOM, and it
should be ignored if it is.
Now the options are mostly generated by hand before being passed
off to jQuery for templating. This fixes much of the speed issues
we had when they were entirely being generated through jQuery.