EPT Settings All the breakpoints must be different

Created on 8 July 2024, 5 months ago
Updated 18 July 2024, 4 months ago

Problem/Motivation

When I view the EPT Settings page and save it, I get the error "All the breakpoints must be different". However, when I check, all the Breakpoints are different in the respective fields.

If I do slightly adjust two of the values for example to the mobile to 641 and tablet to 1021, while leaving the desktop as 1320, then the page saves, but if I wanted to leave the defaults (or change it back) then it doesn't allow me to.

Steps to reproduce

Installed the EPT Core and other EPT modules, go to the EPT Core Setting page and save it with the default breakpoints 640, 1020, 1320 without making any adjustments.

Proposed resolution

Set the default breakpoint values to be different from the width values in the module configuration in ept_core.settings.yml.

Remaining tasks

User interface changes

n/a

API changes

n/a

Data model changes

n/a

🐛 Bug report
Status

Fixed

Version

1.4

Component

User interface

Created by

🇯🇲Jamaica axle_foley00

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @axle_foley00
  • 🇯🇲Jamaica axle_foley00

    I dug into this a little more and found the issue in the src/Form/EptCoreSettingsForm.php file.

        // Define the array with breakpoints values.
        $breakpoint_values = [
          $ept_core_mobile_breakpoint,
          $ept_core_tablet_breakpoint,
          $ept_core_xxsmall_width,
          $ept_core_xsmall_width,
          $ept_core_small_width,
          $ept_core_default_width,
          $ept_core_large_width,
          $ept_core_xlarge_width,
          $ept_core_xxlarge_width,
        ];
    
        // Get the unique breakpoints removing the repeated values.
        $unique_breakpoints = array_unique($breakpoint_values);
    
        // If there is repeated breakpoints, set a validation in the form error.
        if (count($breakpoint_values) !== count($unique_breakpoints)) {
          $form_state->setError($form, $this->t('All the breakpoints must be different'));
        }
    

    So the count of the $breakpoint_values is not equivalent to the count of $unique_breakpoints. But aside from that I noticed that in the array of $breakpoint_values that $ept_core_desktop_breakpoint is also missing. So that is why I only needed to change the mobile and table breakpoint values. Should the breakpoint values be mixed with the Width values in this form validation check?

    Also Is it really necessary for the Breakpoint values to be different from the Width values? If so, then perhaps a proposed solution could be to set the default Breakpoint values to be different from the Width values at module installation time in ept_core.settings.yml.

    Hope that helps.

    • levmyshkin committed a38484d5 on 1.4.x
      Issue #3460052 by axle_foley00: EPT Settings All the breakpoints must be...
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    Hi axle_foley00, thank you for your report! We had the same problem with EBT module:
    https://www.drupal.org/node/3456572

    I removed these variables from validation:

    $ept_core_mobile_breakpoint,
    $ept_core_tablet_breakpoint,

    And released changes in 1.4.11 version:
    https://www.drupal.org/project/ept_core/releases/1.4.11

    You just need to update EPT Core module with composer:

    composer require drupal/ept_core:^1.4.11

  • Status changed to Fixed 5 months ago
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia
  • Status changed to Fixed 5 months ago
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia
  • 🇯🇲Jamaica axle_foley00

    Hey levmyshkin, okay great! Thanks. Confirming it is fixed in the latest update.

    Have a great day.

  • 🇯🇲Jamaica axle_foley00

    I forgot to ask, should the wording in the comments and error message also be updated so say 'width' instead of 'breakpoints' as was done in the EBT module fix?

    For example:

    // Define the array with breakpoints values.

    should be

    // Define the array with width values.

    and

    // Get the unique breakpoints removing the repeated values.

    should be

    // Get the unique width values removing the repeated ones.

    and

    $form_state->setError($form, $this->t('All the breakpoints must be different'));

    should be

    $form_state->setError($form, $this->t('All the width values must be different'));

    and so on?

  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    Yes, sure, thank you! I will fixes for comments and texts in the next release, since it's not urgent and doesn't affect on functionality.

  • 🇯🇲Jamaica axle_foley00

    Ok noted. Thanks again.

  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    Updated comments and messages in 1.4.x branch.

  • 🇯🇲Jamaica axle_foley00

    @levmyshkin, okay thanks. I'll update the modules in my install to get the new changes.

Production build 0.71.5 2024