[Autocomplete] Ensure default plugins are nicely merged with user-defined plugins - #2841
Merged
Merged
Conversation
Contributor
📊 Packages dist files size differenceThanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
|
|||||||||
Kocal
force-pushed
the
1128-auto-complete-get-url
branch
2 times, most recently
from
June 13, 2025 15:38
93b1f34 to
6740a92
Compare
Kocal
commented
Jun 13, 2025
| expect(fetchMock.requests()[1].url).toEqual('/path/to/autocomplete?query=foo'); | ||
| }); | ||
|
|
||
| it('connect with ajax URL on a select element, even when the user define custom TomSelect plugins', async () => { |
Member
Author
There was a problem hiding this comment.
This test fails (as expected), when running on 2.x:
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Uncaught Exception ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: this.getUrl is not a function
❯ TomSelect.call src/controller.ts:264:34
262| // the 'this.XXX' calls inside this method fail
263| load: function (query: string, callback: TomLoadCallback) {
264| const url = this.getUrl(query);
| ^
265| fetch(url)
266| .then((response) => response.json())
❯ Timeout._onTimeout ../../../node_modules/tom-select/src/utils.ts:59:7
❯ listOnTimeout node:internal/timers:594:17
❯ processTimers node:internal/timers:529:7
This error originated in "test/controller.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "connect with ajax URL on a select element, even when the user defined custom TomSelect plugin". It might mean one of the following:
- The error was thrown, while Vitest was running this test.
- If the error occurred after the test had been completed, this was the last documented test before it was thrown.
Kocal
force-pushed
the
1128-auto-complete-get-url
branch
from
June 13, 2025 15:39
6740a92 to
9da1c09
Compare
Kocal
commented
Jun 13, 2025
Comment on lines
+333
to
+336
| plugins: { | ||
| ...this.#normalizePluginsToHash(config1.plugins || {}), | ||
| ...this.#normalizePluginsToHash(config2.plugins || {}), | ||
| }, |
Member
Author
There was a problem hiding this comment.
Converting ['foo'] or [{ name: 'foo', options: {/* ... */} }] to { foo: {/* ... */} } helps us to merge the plugins configurations
smnandre
approved these changes
Jun 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The issue happens because when merging the default configuration and the configuration defined by the user, plugins defined by the users erase plugins defined in the default configuration:
At the moment, when the user didn't define
tom_select_options.plugins, everything works fine:Screenshot
But when configuring
tom_select_options.plugins, some necessary plugins are missing:Screenshot
With this PR,
tom_select_options.pluginsfrom the default configuration and the configuration defined by the user are nicely merged:Screenshots
TODO: