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

Autocomplete: Don't add plugins automaticly when defined #401

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

maartendekeizer
Copy link
Contributor

Q A
Bug fix? no
New feature? no
Tickets Fix #379
License MIT

When plugins option is defined Symfony UX will no longer add some plugins by default. This make it possible to render a autocomplete without clear button extensions for example.

Copy link
Member

@weaverryan weaverryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach - just one comment

if (this.urlValue) {
plugins.virtual_scroll = {};
// automaticly add plugins when NOT explicit configured
if (!this.tomSelectOptionsValue || !this.tomSelectOptionsValue.plugins !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this line right? That extra ! in front of this.tomSelectOptionsValue.plugins looks funny to me.

I'd love to have a test for this. It would live in https://github.com/symfony/ux/blob/2.x/src/Autocomplete/assets/test/controller.test.ts. In the existing pre-connect listener - https://github.com/symfony/ux/blob/2.x/src/Autocomplete/assets/test/controller.test.ts#L23 - we could add:

this.element.tomSelectOptions = event.detail.options;

Then, we could add a test that passes a data-autocomplete-tom-select-options-value="{ plugins: { virtual_scroll: {} } }" and verify with something like getByTestId(container, 'main-element').tomSelectOptions.plugins.toBe({ virtual_scroll: {} }).

@maartendekeizer
Copy link
Contributor Author

@weaverryan Bit off topic but related to solving your feedback: Where can I find information about how to run tests cases etc. I think I am missing a good contribute to symfony/ux page. The part in the readme is very short and is also missing a part about building...

@weaverryan
Copy link
Member

@maartendekeizer that's fair - that could certainly use some help :).

To run tests for a specific component, from the root of the project

yarn install
cd src/Autocomplete/assets
yarn jest

# or to run a specific test
yarn jest -t 'connect without options'

Let me know if that gives you any trouble - the tests can be tricky, but the existing ones in autocomplete should be fairly similar to what you're trying to do.

@weaverryan
Copy link
Member

Friendly ping @maartendekeizer :)

@daFish
Copy link
Contributor

daFish commented Dec 16, 2022

Hey @maartendekeizer is there anything I can help with? 😄

@daFish
Copy link
Contributor

daFish commented Feb 15, 2024

@weaverryan How should we proceed with this PR?

@simonsolutions
Copy link
Contributor

+1 for a solution for this problem. I'm facing it too and would like to have the PR procceded.

@simonsolutions
Copy link
Contributor

I would vote for merging it to the next release please. We really need the fix.

@simonsolutions
Copy link
Contributor

As the PR seems mergable without conflict, when can we expect this fix to be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Autocomplete] Don't want a clear button
5 participants