1
0
mirror of synced 2024-11-23 13:36:01 +03:00
Commit Graph

8 Commits

Author SHA1 Message Date
Kevin Brown
bbd320d75e Convert source and tests to unix newlines 2019-07-20 23:01:38 -04:00
Kevin Brown
d9260254c1
Fix infinite scroll when the scrollbar is not visible (#5575)
Ever since the 4.0.0 release of Select2, there has been a bug where
if you enabled infinite scrolling but did not return enough results
on the first load of AJAX to show a scrollbar, then infinite
scrolling would not be enabled and you could not view anything other
than the first page of results. The solution for this was first
proposed in #3888 but it was closed off because of inactivity and
missing tests.

This fixes the issue by performing the check to see if more results
should be loaded both on scroll and also when the results are first
loaded. This solves the issue that we were seeing before, because
the plugin knows it needs to load in more results, just it did not
receive the scroll event before and thus was not able to actually
load in the new results.

This has the potential to trigger multiple AJAX requests to load in
multiple pages of results if the user has the ability to see many
options, but only a few are being loaded at a time.

This also adds tests for infinite scrolling, both to ensure that
it will attempt to load additional pages, even without the scrollbar,
and to ensure that the regular behaviour of not loading additional
pages when the scrollbar is visible is preserved.

Fixes #3088
2019-07-20 18:09:17 -04:00
Kevin Brown
bd7ac9df03
Results respect disabled state of <option> (#5560)
This check is in place in most other places, mostly because we have
run into widespread issues under similar circumstances and we like to
avoid those, but it was forgotten here. There also were no tests
covering this, so it was never caught.

This adds tests that ensure that the option in the results list will
be generated with the correct "disabled" state based on whether or
not it, or a parent element, is marked as disabled.

This should have been easy: just check `element.disabled`

Unfortunately the `disabled` property is not inherited within the
option chain, so if an `<optgroup>` is disabled, the `<option>`
elements or other `<optgroup>` elements held within it do not have
their `disabled` property set to `true`. As a result, we needed to
use the `matches` method to check if the `:disabled` state is
present for the element. The `matches` method is part of the official
standard, but it was not implemented under that name for a while and
as a result Internet Explorer only supports it under the prefixed
`msMatchesSelector` method and older versions of Webkit have it
implemented as `webkitMatchesSelector`. But once we use this method,
it appears to consistently return the expected results.

This `matches` method and prefixed predecessors are not supported in
IE 8, but they are supported in IE 9 and any browsers newer than
that. Instead of buulding a very hacky solution using
`querySelectorAll` that was brittle, I have chosen to act like
everyone else and pretend IE 8 no longer exists.

Fixes #3347
Closes #4818
2019-07-09 20:58:13 -04:00
Pedro Felipe de Azevedo Furtado
db30f66afc
Update focusing-tests.js 2018-09-15 00:17:56 -03:00
Pedro Felipe de Azevedo Furtado
c2acb18509
Update focusing-tests.js 2018-09-14 23:54:19 -03:00
Bowei Han
2b049c08ab Add scrollAfterSelect as a configurable option for multiselect dropdowns to allow toggling of highlightFirstItem() behaviour (#5150)
* Add scrollOnSelect as a configurable option

* default scrollOnSelect to true to avoid modifying existing behaviour

* added tests and default option for scrollAfterSelect
2018-09-05 17:36:20 -03:00
Kevin Brown
a74547aaa7 Migrate from expect to assert.expect
After we upgraded to QUnit 1.23.1, we gained support for
assert.expect(). This allows us to guard against any race conditions
within tests, because now expect() will be linked to the specific test
instead of the current running test.
2016-05-23 23:38:45 -04:00
Kevin Brown
acd3306192 Added tests for focusing results
This adds three tests related to focusing selected items in the results.
The tests are for e897d00 and 9f58128.
2016-05-14 21:05:30 -04:00