Skip to content

[Autocomplete] Allow plugins to be disabled through tom_select_options.plugins.<plugin> = false - #401

Merged
Kocal merged 1 commit into
symfony:2.xfrom
maartendekeizer:issue_379
Jul 24, 2025
Merged

[Autocomplete] Allow plugins to be disabled through tom_select_options.plugins.<plugin> = false#401
Kocal merged 1 commit into
symfony:2.xfrom
maartendekeizer:issue_379

Conversation

@maartendekeizer

@maartendekeizer maartendekeizer commented Jul 26, 2022

Copy link
Copy Markdown
Contributor
Q A
Bug fix? no
New feature? yes
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.

@weaverryan weaverryan left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread src/Autocomplete/assets/src/controller.ts Outdated
@maartendekeizer

Copy link
Copy Markdown
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
Copy Markdown
Contributor

@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
Copy Markdown
Contributor

Friendly ping @maartendekeizer :)

@daFish

daFish commented Dec 16, 2022

Copy link
Copy Markdown
Contributor

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

@daFish

daFish commented Feb 15, 2024

Copy link
Copy Markdown
Contributor

@weaverryan How should we proceed with this PR?

@simonsolutions

Copy link
Copy Markdown
Contributor

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

@simonsolutions

Copy link
Copy Markdown
Contributor

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

@simonsolutions

Copy link
Copy Markdown
Contributor

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

@Kocal

Kocal commented Jul 23, 2025

Copy link
Copy Markdown
Member

Working on it

@Kocal Kocal changed the title Autocomplete: Don't add plugins automaticly when defined [Autocomplete] Allow plugins to be disabled through tom_select_options.plugins.<plugin> = false Jul 23, 2025
@github-actions

github-actions Bot commented Jul 23, 2025

Copy link
Copy Markdown
Contributor

📊 Packages dist files size difference

Thanks for the PR! Here is the difference in size of the packages dist files between the base branch and the PR.
Please review the changes and make sure they are expected.

FileBefore (Size / Gzip)After (Size / Gzip)
Autocomplete
controller.js 17.61 kB / 4.13 kB 18.01 kB+2% 📈 / 4.21 kB+2% 📈

@Kocal

Kocal commented Jul 23, 2025

Copy link
Copy Markdown
Member

I've pushed a new commit that allows default plugins to be disableable when passing false, e.g.:

<?php
#[AsEntityAutocompleteField]
class IngredientAutocompleteType extends AbstractType
{
    public function configureOptions(OptionsResolver $resolver): void
    {
        $resolver->setDefaults([
            'class' => Ingredient::class,
            'tom_select_options' => [
                'plugins' => [
                    'clear_button' => false, // Disable the clear button
                    'remove_button' => false, // Disable the remove button
                ],
            ],
        ]);
    }

    public function getParent(): string
    {
        return BaseEntityAutocompleteType::class;
    }
}

I added some tests too

@Kocal Kocal added the Status: Needs Review Needs to be reviewed label Jul 23, 2025
@Kocal
Kocal requested review from kbond and smnandre July 23, 2025 21:42
@carsonbot carsonbot added Status: Reviewed Has been reviewed by a maintainer and removed Status: Needs Review Needs to be reviewed labels Jul 23, 2025
@Kocal Kocal added the Feature New Feature label Jul 24, 2025
@Kocal

Kocal commented Jul 24, 2025

Copy link
Copy Markdown
Member

Thank you @maartendekeizer.

@Kocal
Kocal merged commit e186a23 into symfony:2.x Jul 24, 2025
@CODEheures

Copy link
Copy Markdown

Thank you all. I don't find this in current documentation, but it work.

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

Labels

Autocomplete Feature New Feature Status: Reviewed Has been reviewed by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Autocomplete] Don't want a clear button

8 participants