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

Filter's behavior has changed or is broken after migration to stimulus #8241

Closed
p-golovin opened this issue Feb 10, 2025 · 6 comments · Fixed by #8242
Closed

Filter's behavior has changed or is broken after migration to stimulus #8241

p-golovin opened this issue Feb 10, 2025 · 6 comments · Fixed by #8242

Comments

@p-golovin
Copy link

Environment

Sonata packages

show

$ composer show --latest 'sonata-project/*'

Direct dependencies required in composer.json:
sonata-project/admin-bundle              4.35.2 4.35.2 The missing Symfony Admin Generator
sonata-project/doctrine-orm-admin-bundle 4.18.0 4.18.0 Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/intl-bundle               3.2.0  3.2.0  Symfony SonataIntlBundle
sonata-project/translation-bundle        3.3.0  3.3.0  SonataTranslationBundle
sonata-project/user-bundle               5.14.0 5.14.0 Symfony SonataUserBundle

Transitive dependencies not required in composer.json:
sonata-project/block-bundle              5.1.2  5.1.2  Symfony SonataBlockBundle
sonata-project/doctrine-extensions       2.5.0  2.5.0  Doctrine2 behavioral extensions
sonata-project/exporter                  3.3.1  3.3.1  Lightweight Exporter library
sonata-project/form-extensions           2.4.1  2.4.1  Symfony form extensions
sonata-project/twig-extensions           2.5.0  2.5.0  Sonata twig extensions```

Symfony packages

show

$ composer show --latest 'symfony/*'

Direct dependencies required in composer.json:
symfony/browser-kit                6.4.13 7.2.0  Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically
symfony/console                    6.4.17 7.2.1  Eases the creation of beautiful and testable command line interfaces
symfony/css-selector               6.4.13 7.2.0  Converts CSS selectors to XPath expressions
symfony/debug-bundle               6.4.13 7.2.0  Provides a tight integration of the Symfony VarDumper component and the ServerLogCommand from MonologBridge into the Symfony full-stack framework
symfony/dotenv                     6.4.16 7.2.0  Registers environment variables from a .env file
symfony/flex                       2.4.7  2.4.7  Composer plugin for Symfony
symfony/framework-bundle           6.4.18 7.2.3  Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/html-sanitizer             6.4.18 7.2.3  Provides an object-oriented API to sanitize untrusted HTML input for safe insertion into a document's DOM.
symfony/http-client                6.4.18 7.2.3  Provides powerful methods to fetch HTTP resources synchronously or asynchronously
symfony/mailer                     6.4.18 7.2.3  Helps sending emails
symfony/maker-bundle               1.62.1 1.62.1 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/mime                       6.4.18 7.2.3  Allows manipulating MIME messages
symfony/monolog-bundle             3.10.0 3.10.0 Symfony MonologBundle
symfony/phpunit-bridge             7.2.0  7.2.0  Provides utilities for PHPUnit, especially user deprecation notices management
symfony/runtime                    6.4.14 7.2.3  Enables decoupling PHP applications from global state
symfony/security-bundle            6.4.13 7.2.3  Provides a tight integration of the Security component into the Symfony full-stack framework
symfony/twig-bundle                6.4.13 7.2.0  Provides a tight integration of Twig into the Symfony full-stack framework
symfony/web-profiler-bundle        6.4.18 7.2.3  Provides a development tool that gives detailed information about the execution of any request
symfony/yaml                       6.4.18 7.2.3  Loads and dumps YAML files

Transitive dependencies not required in composer.json:
symfony/amqp-messenger             6.4.13 7.2.3  Symfony AMQP extension Messenger Bridge
symfony/asset                      6.4.13 7.2.0  Manages URL generation and versioning of web assets such as CSS stylesheets, JavaScript files and image files
symfony/cache                      6.4.18 7.2.3  Provides extended PSR-6, PSR-16 (and tags) implementations
symfony/cache-contracts            3.5.1  3.5.1  Generic abstractions related to caching
symfony/clock                      6.4.13 7.2.0  Decouples applications from the system clock
symfony/config                     6.4.14 7.2.3  Helps you find, load, combine, autofill and validate configuration values of any kind
symfony/dependency-injection       6.4.16 7.2.3  Allows you to standardize and centralize the way objects are constructed in your application
symfony/deprecation-contracts      3.5.1  3.5.1  A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge            6.4.18 7.2.3  Provides integration for Doctrine with various Symfony components
symfony/dom-crawler                6.4.18 7.2.3  Eases DOM navigation for HTML and XML documents
symfony/error-handler              6.4.18 7.2.3  Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher           6.4.13 7.2.0  Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts 3.5.1  3.5.1  Generic abstractions related to dispatching event
symfony/expression-language        6.4.13 7.2.0  Provides an engine that can compile and evaluate expressions
symfony/filesystem                 6.4.13 7.2.0  Provides basic utilities for the filesystem
symfony/finder                     6.4.17 7.2.2  Finds files and directories via an intuitive fluent interface
symfony/form                       6.4.13 7.2.3  Allows to easily create, process and reuse HTML forms
symfony/http-client-contracts      3.5.2  3.5.2  Generic abstractions related to HTTP clients
symfony/http-foundation            6.4.18 7.2.3  Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                6.4.18 7.2.3  Provides a structured process for converting a Request into a Response
symfony/intl                       6.4.15 7.2.0  Provides access to the localization data of the ICU library
symfony/lock                       6.4.13 7.2.3  Creates and manages locks, a mechanism to provide exclusive access to a shared resource
symfony/messenger                  6.4.16 7.2.3  Helps applications send and receive messages to/from other applications or via message queues
symfony/monolog-bridge             6.4.13 7.2.0  Provides integration for Monolog with various Symfony components
symfony/options-resolver           6.4.16 7.2.0  Provides an improved replacement for the array_replace PHP function
symfony/password-hasher            6.4.13 7.2.0  Provides password hashing utilities
symfony/process                    6.4.15 7.2.0  Executes commands in sub-processes
symfony/property-access            6.4.18 7.2.3  Provides functions to read and write from/to an object or array using a simple string notation
symfony/property-info              6.4.18 7.2.3  Extracts information about PHP class' properties using metadata of popular sources
symfony/routing                    6.4.18 7.2.3  Maps an HTTP request to a set of configuration variables
symfony/scheduler                  6.4.18 7.2.3  Provides scheduling through Symfony Messenger
symfony/security-acl               3.3.4  3.3.4  Symfony Security Component - ACL (Access Control List)
symfony/security-core              6.4.18 7.2.3  Symfony Security Component - Core Library
symfony/security-csrf              6.4.13 7.2.3  Symfony Security Component - CSRF Library
symfony/security-http              6.4.18 7.2.3  Symfony Security Component - HTTP Integration
symfony/serializer                 6.4.18 7.2.3  Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.
symfony/service-contracts          3.5.1  3.5.1  Generic abstractions related to writing services
symfony/stimulus-bundle            2.22.1 2.23.0 Integration with your Symfony app & Stimulus!
symfony/stopwatch                  6.4.13 7.2.2  Provides a way to profile code
symfony/string                     6.4.15 7.2.0  Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way
symfony/translation                6.4.13 7.2.2  Provides tools to internationalize your application
symfony/translation-contracts      3.5.1  3.5.1  Generic abstractions related to translation
symfony/twig-bridge                6.4.17 7.2.2  Provides integration for Twig with various Symfony components
symfony/validator                  6.4.18 7.2.3  Provides tools to validate values
symfony/var-dumper                 6.4.18 7.2.3  Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter               6.4.13 7.2.0  Allows exporting any serializable PHP data structure to plain PHP code

PHP version

$ php -v

PHP 8.3.16 (cli) (built: Jan 14 2025 18:25:29) (NTS gcc aarch64)
Copyright (c) The PHP Group
Zend Engine v4.3.16, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.16, Copyright (c), by Zend Technologies```

Subject

After upgrading from 4.34.0 to 4.35.2 work of filters is changed or broken:

  1. Checkbox become not clickable

Before:
Image

After:
Image

  1. Filters list panel is closed after single filter is checked/unchecked

Before:
Image

After:
Image

  1. Filter with default value can not be turnoff
    protected function configureDefaultFilterValues(array &$filterValues): void
    {
        $filterValues['dateTime']['value'] = [
            'start' => \IntlDateFormatter::formatObject(
                new \DateTime('-12 hours'),
                [\IntlDateFormatter::SHORT, \IntlDateFormatter::MEDIUM]
            ),
            'end' => \IntlDateFormatter::formatObject(
                new \DateTime('+12 hours'),
                [\IntlDateFormatter::SHORT, \IntlDateFormatter::MEDIUM]
            ),
        ];
    }

Before:
Image

After:
Image

Minimal repository with the bug

Tested on 4.35.2, but I think that it is introduced in 4.35.0 with move to stimulus-bundle.

Steps to reproduce

Expected results

  1. Checkboxes in filers list are clickable

  2. Filters list is not closed after check/uncheck one filter

  3. Only turned on filters are applied

Actual results

  1. Checkboxes in filers list are not clickable

  2. Filters list is closed after check/uncheck one filter

  3. Filters with default values are applied too

@VincentLanglet
Copy link
Member

So it would be #8230

cc @onEXHovia

@onEXHovia
Copy link
Contributor

@p-golovin thanks for reporting, I'll check it out soon.

@onEXHovia onEXHovia mentioned this issue Feb 11, 2025
3 tasks
@onEXHovia
Copy link
Contributor

@p-golovin can you provide field defenition dateTime in configureDatagridFilters method?

@p-golovin
Copy link
Author

@onEXHovia

    protected function configureDatagridFilters(DatagridMapper $filter): void
    {
        parent::configureDatagridFilters($filter);

        $filter->add('dateTime', DateTimeRangeFilter::class, [], [
            'field_type' => DateTimeRangePickerType::class,
            'field_options' => [
                'field_options' => [
                    'model_timezone' => 'UTC',
                    'format' => \IntlDateFormatter::SHORT,
                ],
            ],
        ]);
    }

@onEXHovia
Copy link
Contributor

@onEXHovia

    protected function configureDatagridFilters(DatagridMapper $filter): void
    {
        parent::configureDatagridFilters($filter);

        $filter->add('dateTime', DateTimeRangeFilter::class, [], [
            'field_type' => DateTimeRangePickerType::class,
            'field_options' => [
                'field_options' => [
                    'model_timezone' => 'UTC',
                    'format' => \IntlDateFormatter::SHORT,
                ],
            ],
        ]);
    }

Could you see if #8242 fixes your issue?

@p-golovin
Copy link
Author

p-golovin commented Feb 11, 2025

@onEXHovia

  1. Fixed
  2. Fixed
  3. Fixed

Thank you for such quick fix!

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

Successfully merging a pull request may close this issue.

3 participants