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] autoimport bootstrap option is reset to default when doing a composer update #1307

Closed
nayodahl opened this issue Nov 29, 2023 · 6 comments · Fixed by #1316
Closed

Comments

@nayodahl
Copy link

Issue

When I perform a composer update on my project, the autoimport bootstrap option is always reset to default value.
Like this :
image

Files

Here is my composer.json file, i'm running on a docker image (php:8.2-apache) with php8.2 and node18 installed.

{
    "name": "test",
    "description": "test",
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=8.2",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "api-platform/core": "^3.2.6",
        "doctrine/annotations": "^2.0.1",
        "doctrine/doctrine-bundle": "^2.11.1",
        "doctrine/doctrine-migrations-bundle": "^3.3.0",
        "doctrine/orm": "^2.17.1",
        "mhujer/breadcrumbs-bundle": "^1.5.8",
        "nelmio/cors-bundle": "^2.3.1",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.24.4",
        "stof/doctrine-extensions-bundle": "^1.9.0",
        "symfony/apache-pack": "^1.0.1",
        "symfony/asset": "6.3.*",
        "symfony/console": "6.3.*",
        "symfony/dotenv": "6.3.*",
        "symfony/expression-language": "6.3.*",
        "symfony/flex": "^2.4.1",
        "symfony/form": "6.3.*",
        "symfony/framework-bundle": "6.3.*",
        "symfony/html-sanitizer": "6.3.*",
        "symfony/http-client": "6.3.*",
        "symfony/mailer": "6.3.*",
        "symfony/mailjet-mailer": "6.3.*",
        "symfony/monolog-bundle": "^3.10",
        "symfony/password-hasher": "6.3.*",
        "symfony/property-access": "6.3.*",
        "symfony/property-info": "6.3.*",
        "symfony/runtime": "6.3.*",
        "symfony/security-bundle": "6.3.*",
        "symfony/serializer": "6.3.*",
        "symfony/stimulus-bundle": "^2.13.2",
        "symfony/twig-bundle": "6.3.*",
        "symfony/ux-autocomplete": "^2.13.2",
        "symfony/validator": "6.3.*",
        "symfony/webpack-encore-bundle": "^2.1.1",
        "symfony/workflow": "6.3.*",
        "symfony/yaml": "6.3.*",
        "symfonycasts/reset-password-bundle": "^1.18",
        "twig/extra-bundle": "^2.12|^3.8.0",
        "twig/intl-extra": "^3.8.0",
        "twig/twig": "^2.12|^3.8.0"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.5.1",
        "friendsofphp/php-cs-fixer": "^3.40.0",
        "jangregor/phpstan-prophecy": "^1.0",
        "php-parallel-lint/php-var-dump-check": "^0.5.0",
        "phpspec/prophecy-phpunit": "^2.0.2",
        "phpstan/phpstan": "^1.10.46",
        "phpstan/phpstan-doctrine": "^1.3.53",
        "phpstan/phpstan-phpunit": "^1.3.15",
        "phpstan/phpstan-symfony": "^1.3.5",
        "phpunit/phpunit": "^9.6.13",
        "symfony/browser-kit": "6.3.*",
        "symfony/css-selector": "6.3.*",
        "symfony/debug-bundle": "6.3.*",
        "symfony/maker-bundle": "^1.51.1",
        "symfony/phpunit-bridge": "^6.3.8",
        "symfony/stopwatch": "6.3.*",
        "symfony/web-profiler-bundle": "6.3.*",
        "zenstruck/foundry": "^1.36"
    },
    "config": {
        "allow-plugins": {
            "php-http/discovery": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php73": "*",
        "symfony/polyfill-php74": "*",
        "symfony/polyfill-php80": "*",
        "symfony/polyfill-php81": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "6.3.*"
        }
    }
}

I want to keep the bootstrap4 option, of course.
Not sure exactly what is happening here.
Any feedback appreciated, thanks.

@smnandre
Copy link
Member

smnandre commented Nov 29, 2023

symfony/ux-autocomplete is provided with two options (bootstrap5 or the default css) since end of 2022 / early 2023.

You should not add / remove entries from this file (controllers.json), but it can be used to enable/disable features, set lazy loading, etc.

In your situation, i'd write "false" for both the CSS suggested, and i'd import manually the bootstrap4 CSS

See the AssetMapper documentation there: https://symfony.com/doc/current/frontend/asset_mapper.html#lazily-importing-css-from-a-javascript-file

@danakil
Copy link

danakil commented Nov 29, 2023

I just ran into the same problem, glad I've seen this issue !
It's counter-intuitive (for me) but
import 'tom-select/dist/css/tom-select.bootstrap4.css';
in app.js did the job, thank you.

@nayodahl
Copy link
Author

Thanks for you help @smnandre @danakil , it did the trick indeed.
For my information, do you have any idea what script is involved in resetting this config file ?
I don't see anything suspicious on composer.json, scripts part :

    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"

It's the first time I notice this type of behavior

@smnandre
Copy link
Member

I'm not sure 100% in your case because i'm not too familiar with WebpackEncore + StimulusBundle, but things start with Flex, which reacts after a symfony bundle is installed / updated and synchronize config files : importmap.php or package.json and assets/controllers.json ( https://github.com/symfony/flex/blob/2.x/src/PackageJsonSynchronizer.php )

@smnandre
Copy link
Member

If you want to open a PR on symfony/ux-autocomplete, don't hesitate to do... it would be well received :)

I think it would just need to add the bootstrap4 in this file (false per default) : https://github.com/symfony/ux-autocomplete/blob/2.x/assets/package.json

@nayodahl
Copy link
Author

Done : #1316

weaverryan added a commit that referenced this issue Dec 12, 2023
…le (Anthony FACHAUX)

This PR was merged into the 2.x branch.

Discussion
----------

add tom-select bootstrap4 css file to default config file

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| Issues        | Fix #1307
| License       | MIT

Add tom-select bootstrap4 css file to default config file.
Without this, if you have replaced the bootstrap5.css value with a boostrap4 with value set to true, it will be replaced every time you perform a composer update (with the help of flex).

Like this :
![image](https://github.com/symfony/ux/assets/63842196/9a436c6b-3efb-4d61-98ce-e0e8a14da68c)

Commits
-------

d5ca775 add tom-select bootstrap4 css file to default config file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants