1
0
mirror of synced 2024-11-23 05:26:10 +03:00
Commit Graph

27 Commits

Author SHA1 Message Date
Kevin Brown
f2d527ea97
Do not propagate click when search box is not empty (#5580)
This fixes a long-standing bug where if you tried to click in the
search box for a multiple select while there was text in it, the
dropdown would close and the text would be cleared. This caused
many unexpected issues, because it meant that you could only use
your keyboard to edit text within the search box.

This will still clear out the search field if you click within the
area of the selection which is not the search field. I'm not sure
if that is also unexpected behaviour, so for now I am going to
maintain it.

Fixes #3517
Fixes #3808
Fixes #5491
Closes #5551
2019-07-21 13:04:51 -04:00
Kevin Brown
bbd320d75e Convert source and tests to unix newlines 2019-07-20 23:01:38 -04:00
Kevin Brown
1b5a962819
Revert change to focusing behaviour in 4.0.6 (#5576)
This behaviour, where the focus was happening on a small asynchronous
delay, was added in commit 933189b92 late last year in a commit with
no supporting tickets or commit message explaining what the change
was trying to accomplish. This commit has effectly been reverted within
this commit, since it caused a regression in how focus was being
assigned that made it inconsistent with a standard `<select>`.

A test was added for this which ensures that we won't see that
regression again.

Fixes #5532
Fixes #5185
Closes #5552
2019-07-20 22:44:28 -04:00
Nisha Kaushik
14a059d7ee #4530 Add tooltip (title) to the 'remove all' 'X' icon. (#5291)
* #4530 Add tooltip (title) to the 'remove all' 'X' icon.

* #4530 Add tooltip (title) to the 'remove all' 'X' icon.

* #4530 Add tooltip (title) to the 'remove all'

* Revert dist folder.

* add tk.js from pull request.
2018-09-15 16:22:54 -03:00
Tim Kang
a395ad1d75 Add failing tests
See #3895
2017-10-26 12:59:04 -04:00
Krzysztof Śmiałek
04d3a5da66 Add dedicated event for clearing
Closes #4929, #5045.
2017-10-26 00:30:31 -04:00
Krzysztof Śmiałek
10bda78b37 Fix value not being cleared when unselect event is emitted
Fixes #5049.
2017-10-26 00:30:24 -04: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
5b207b287e Add test for focus event on inline search
This adds a test for
02cca7baa7.
2016-04-23 21:38:41 -04:00
Kevin Brown
e08222ef15 Tests for the inline search box
This adds tests for the following commits

5f80c5d9f8

395e06aff5
2015-11-23 18:25:09 -05:00
Kevin Brown
7d8f86cbf8 Add tests for removing a selection when disabled
These tests should fail because a selection can be removed even
though the container is disabled. This is because the only thing
preventing selections from being removed was the CSS which hid the
remove buttons when the container was disabled.
2015-08-19 20:59:39 -04:00
Kevin Brown
dd2990adea Skip focus test on IE 8
I can't reproduce this test failure on and IE 8 virtual machine, so
I'm just going to skip it on IE 8.
2015-08-09 21:00:48 -04:00
Kevin Brown
88503d2c67 Add test for 698fe7b
This adds the test that ensures that the search focus is still
focused, even after the selection is updated (for whatever reason).
Note that we are not triggering the `change` event here, and are
instead just re-calling `update` on the selection adapter. This is
because we do not bind the `change` event in tests, so the selection
is never re-rendered and the tests will pass. The `update` method
is triggered during the `change` cycle anyway, so this has the
same effect while supporting cases where the selection is re-rendered
without the selected values changing.
2015-06-21 21:42:06 -04:00
Stretch
e60ab22a85 Adding single select support and testing 2015-06-10 20:05:07 +10:00
Stretch
581af39288 #3222 test cleanup
Improving my test from feedback.
2015-05-08 08:03:46 +10:00
Stretch
13cead0bd0 Adding container support #3222
Fixes issue #3222
Now templateSelection can have access to the parent container so that
classes can be added for styling
2015-05-07 21:59:51 +10:00
Kevin Brown
f3f1b31958 Add back *css* options through an adapter
The old functionality where classes were directly copied to the
container can be done by setting `dropdownCssClass: ':all:'` when
initializing Select2.

This closes https://github.com/select2/select2/issues/2879.
2015-04-05 21:58:02 -04:00
Kevin Brown
b9b55cec44 Tests use jQuery 1.7.2
As jQuery 1.7.2 is the lowest version of jQuery supported by Select2,
it makes sense to run the tests on it. For the most part, we can
assume that the newer versions of Select2 are backwards compatible
enough such that this isn't an issue.

The recommended version of jQuery to use is the latest though, which
is why the jQuery file is only included in the tests.

This revealed a few issues with our data fallbacks and `.append`
functionality that was introduced in jQuery 1.8.
2015-03-11 19:20:41 -04:00
Kevin Brown
72e5c2a50d Combine tests into common files
This groups tests into common HTML files so they can be run more
quickly. This also reduces the number of Sauce Labs instances that
have to be run, as one instance was previously spun up for each
file.
2015-02-13 23:29:56 -05:00
Kevin Brown
8f8140e3b0 Added modules for stopping event propagation
This adds `StopPropagation` modules that will stop the propagation
of the most common events from the selection and dropdown containers.
These modules work from a list of 21 common events, most of which
were stopped by default in past versions, and call `stopPropagation`
on them when they are detected at the container level.

These modules are only available in full builds of Select2.

This closes https://github.com/select2/select2/issues/2033.
This closes https://github.com/select2/select2/issues/2974.
2015-02-09 20:04:01 -05:00
Kevin Brown
4dda5e7a74 Hide the search clear icon in webkit
The search box previously displayed a clear icon on the far right
side in webkit-based browsers, specifically Chrome and Safari. This
hides the clear icon in those browsers, and also fixes a slight
sizing issue, so it should no longer be displayed.

This also disables autocorrect, autocompleted, as well as a few
other automatic search corrections on the field, so mobile devices
should have a better experience.

This closes https://github.com/select2/select2/issues/3018.
2015-02-09 15:29:28 -05:00
Kevin Brown
5a0f7f5518 Added back escapeMarkup
This is needed to escape any bad markup that is passed through
user-entered data. Users can prevent their markup from being
escaped by using a no-op `escapeMarkup` function.

This closes https://github.com/select2/select2/issues/2990.
2015-01-29 09:15:02 -05:00
Kevin Brown
686f846fa5 Changed how the builds are done
This adds a check that triggers an error if Select2 was not able
to detect a copy of jQuery on the page. This should help users when
they are setting up Select2.

**Breaking change:** The full build no longer includes jQuery.
Previously, the full build included all requirements for Select2,
including jQuery, which meant that anyone looking for the optional
requirements had to possibly include multiple versions of jQuery
on their page. This means that anyone requiring Select2 to also
bundle jQuery will now need to include jQuery on their pages
alongside Select2. A copy of jQuery is included in the repository.

**Breaking change:** The AMD build of Select2 will now correctly
wrap the code in a `define` block. It will still create the named
blocks inside of the code, which should be valid in most AMD build
systems, so now Select2 is compatible with cases where the file
does not have the same name as the Select2 module name.

**Breaking change:** Select2 will re-use the AMD methods if they
are available on the page, but it will not longer leak the included
AMD loader to the global scope. The AMD methods will still be
available on the `jQuery.fn.select2.amd` namespace.

The `mock.js` test file has been renamed to `helpers.js` and will
handle the escalation of the `require` and `define` variables to
the global scope. It should be included in all test files, or the
tests will fail.

This closes https://github.com/select2/select2/issues/2946.
2015-01-22 14:49:39 -05:00
Kevin Brown
d81886e5de Trigger the unselect event when clearing placeholder
In the past, Select2 triggered the `select2-clearing` event when
clearing the placeholder. This has been switched to the `unselect`
event which is now triggered whenever the placeholder is cleared.
The placeholder can also be prevented if the `unselecting` event
is prevented.

This will also trigger the event when deleting every option from
the multiple select, so it is possible for the `unselecting` event
to be triggered multiple times when clearing a multiple select.

This adds tests to ensure that the `allowClear` option always works.

This closes https://github.com/select2/select2/issues/2954.
2015-01-21 19:11:07 -05:00
Kevin Brown
024d41b412 Normalize internal select/unselect events
Also pull the logic for automatically closing the dropdown into the
dropdown adapter, taking it out of the core.

The `selected` and `unselected` events are now `select` and
`unselect`, which is what many of the other adapters were expecting
them to be.

Some tests for placeholders have been added.
2015-01-09 10:05:44 -05:00
Kevin Brown
43efd43d57 Add tests for the multiple selection container 2014-11-26 20:50:39 -05:00
Kevin Brown
4cab421966 Added tests for the single selection container 2014-11-26 20:25:56 -05:00