From de8e9fc5d81e368e64db54053f12e5f54d83e264 Mon Sep 17 00:00:00 2001 From: Tiberiu Dumitru Date: Wed, 16 Apr 2025 15:02:49 +0300 Subject: [PATCH 1/2] feat(ids): Lower probability of same id twice on page. - OEL-3642 --- src/components/bcl-accordion/accordion.html.twig | 4 ++-- src/components/bcl-dropdown/dropdown.html.twig | 2 +- src/components/bcl-modal/modal.html.twig | 4 ++-- src/compositions/bcl-file/file-translations.html.twig | 4 ++-- src/compositions/bcl-gallery/gallery.html.twig | 4 ++-- .../bcl-language-switcher/language-switcher.html.twig | 4 ++-- src/compositions/bcl-timeline/timeline.html.twig | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/bcl-accordion/accordion.html.twig b/src/components/bcl-accordion/accordion.html.twig index d6dfc108d..90d4acee5 100644 --- a/src/components/bcl-accordion/accordion.html.twig +++ b/src/components/bcl-accordion/accordion.html.twig @@ -6,7 +6,7 @@ - title_tag (string) (default: 'h2') - title_link: (link object) (default: {}) - title_attributes: (drupal attrs) - - id (int) (default: random(1000)) + - id (int) (default: random(10000)) - flush (boolean) (default: false) - items (array) (default: []): format: [ { @@ -26,7 +26,7 @@ {% set _title_tag = title_tag|default('h2') %} {% set _title_link = title_link|default({}) %} {% set _title_attributes = title_attributes ?: create_attribute() %} -{% set _id = id|default(random(1000)) %} +{% set _id = id|default(random(10000)) %} {% set _flush = flush ?? false %} {% set _items = items|default([]) %} {% set _expand_button = expand_button|default({}) %} diff --git a/src/components/bcl-dropdown/dropdown.html.twig b/src/components/bcl-dropdown/dropdown.html.twig index 1798b6af0..cc641c4e3 100644 --- a/src/components/bcl-dropdown/dropdown.html.twig +++ b/src/components/bcl-dropdown/dropdown.html.twig @@ -1,7 +1,7 @@ {% apply spaceless %} {# Parameters: - - id (string) (default: dropdown-random(1000)) + - id (string) (default: dropdown-random(10000)) - trigger (link or button) - link (boolean) (default: false) - direction (string) (default: '') diff --git a/src/components/bcl-modal/modal.html.twig b/src/components/bcl-modal/modal.html.twig index fa3916a9b..78eb3f529 100644 --- a/src/components/bcl-modal/modal.html.twig +++ b/src/components/bcl-modal/modal.html.twig @@ -3,7 +3,7 @@ {# Parameters: - size (string) default('') options: sm, lg, xl, fullscreen - - id (boolean) (default: modal-random(1000)) + - id (boolean) (default: modal-random(10000)) - fullscreen_responsive (string) (default: '') options: sm, md, lg, xl, xxl - static_backdrop (boolean) (default: false) @@ -23,7 +23,7 @@ #} {% set _size = size|default('') %} -{% set _id = id|default('modal-' ~ random(1000)) %} +{% set _id = id|default('modal-' ~ random(10000)) %} {% set _fullscreen_responsive = fullscreen_responsive|default('') %} {% set _static_backdrop = static_backdrop ?? false %} {% set _verticaly_centered = verticaly_centered ?? false %} diff --git a/src/compositions/bcl-file/file-translations.html.twig b/src/compositions/bcl-file/file-translations.html.twig index 090e53ad8..af1d29bf3 100644 --- a/src/compositions/bcl-file/file-translations.html.twig +++ b/src/compositions/bcl-file/file-translations.html.twig @@ -1,7 +1,7 @@ {% apply spaceless %} {# Parameters: - - id (string) (default: language-dropdown-random(1000)) + - id (string) (default: language-dropdown-random(10000)) - label (string) (default: '') - icon_path (string) (default: '') - items (string) (default: []) @@ -15,7 +15,7 @@ ] #} -{% set _id = id|default('language-dropdown' ~ random(1000)) %} +{% set _id = id|default('language-dropdown' ~ random(10000)) %} {% set _label = label|default('') %} {% set _icon_path = icon_path|default('') %} {% set _items = items|default([]) %} diff --git a/src/compositions/bcl-gallery/gallery.html.twig b/src/compositions/bcl-gallery/gallery.html.twig index c9a3c4e12..02dacb5dd 100644 --- a/src/compositions/bcl-gallery/gallery.html.twig +++ b/src/compositions/bcl-gallery/gallery.html.twig @@ -2,7 +2,7 @@ {# Parameters: - - id (string) (default: gallery-random(1000)) + - id (string) (default: gallery-random(10000)) - title (string) (default: '') - title_tag (string) (default: 'h2') - title_link: (link object) (default: {}) @@ -28,7 +28,7 @@ Parameters: carousel #} -{% set _id = id|default('gallery-' ~ random(1000)) %} +{% set _id = id|default('gallery-' ~ random(10000)) %} {% set _title = title|default('') %} {% set _title_tag = title_tag|default('h2') %} {% set _title_link = title_link|default({}) %} diff --git a/src/compositions/bcl-language-switcher/language-switcher.html.twig b/src/compositions/bcl-language-switcher/language-switcher.html.twig index 82c809b60..aef75910a 100644 --- a/src/compositions/bcl-language-switcher/language-switcher.html.twig +++ b/src/compositions/bcl-language-switcher/language-switcher.html.twig @@ -1,13 +1,13 @@ {% apply spaceless %} {# Parameters: - - id (string) (default: collapse-random(1000), optional) + - id (string) (default: collapse-random(10000), optional) - message (alert object) (default: {}) - expandable (button object) (default: {}) - languages (link[]) (default: []) #} -{% set _id = id|default('collapse-' ~ random(1000)) %} +{% set _id = id|default('collapse-' ~ random(10000)) %} {% set _message = message|default({}) %} {% set _expandable = expandable|default({}) %} {% set _languages = languages|default([]) %} diff --git a/src/compositions/bcl-timeline/timeline.html.twig b/src/compositions/bcl-timeline/timeline.html.twig index c9920b265..cab57aea3 100644 --- a/src/compositions/bcl-timeline/timeline.html.twig +++ b/src/compositions/bcl-timeline/timeline.html.twig @@ -2,7 +2,7 @@ {# Parameters: - - id: (integer) (default: random(1000)) + - id: (integer) (default: random(10000)) - title: (string) (default: '') - title_tag: (string) (default: 'h2') - title_link: (link object) (default: {}) @@ -25,7 +25,7 @@ Parameters: - icon_path (string) (default: ''): file containing the svg icons #} -{% set _id = id|default(random(1000)) %} +{% set _id = id|default(random(10000)) %} {% set _title = title|default('') %} {% set _title_tag = title_tag|default('h2') %} {% set _title_link = title_link|default({}) %} From 1ad4bb145a45fc02d75e4ef1a691bc7cc55fb68e Mon Sep 17 00:00:00 2001 From: Tiberiu Dumitru Date: Mon, 28 Apr 2025 14:13:00 +0300 Subject: [PATCH 2/2] OEL-3642: Inpage increased random. --- .../bcl-inpage-navigation/inpage-navigation.html.twig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compositions/bcl-inpage-navigation/inpage-navigation.html.twig b/src/compositions/bcl-inpage-navigation/inpage-navigation.html.twig index 4226ca2c9..be0d78e94 100644 --- a/src/compositions/bcl-inpage-navigation/inpage-navigation.html.twig +++ b/src/compositions/bcl-inpage-navigation/inpage-navigation.html.twig @@ -7,8 +7,8 @@ Parameters: - title_link: (link object) (default: {}) - title_attributes (drupal attrs) - links: (link[]) (default: []) - - id (string) (default: bcl-inpage-navigation-random(100)) - - dropdown_id (string) (default: bcl-inpage-navigation-dropdown-random(100)) + - id (string) (default: bcl-inpage-navigation-random(10000)) + - dropdown_id (string) (default: bcl-inpage-navigation-dropdown-random(10000)) - dynamic_active: (boolean) (default: false) - icon_path (string) (default: '') - attributes (drupal attrs) @@ -19,9 +19,9 @@ Parameters: {% set _title_link = title_link|default({}) %} {% set _title_attributes = title_attributes ?: create_attribute() %} {% set _links = links|default([]) %} -{% set _id = id|default('bcl-inpage-navigation-' ~ random(100)) %} +{% set _id = id|default('bcl-inpage-navigation-' ~ random(10000)) %} {% set _icon_path = icon_path|default('') %} -{% set _dropdown_id = dropdown_id|default('bcl-inpage-navigation-dropdown' ~ random(100)) %} +{% set _dropdown_id = dropdown_id|default('bcl-inpage-navigation-dropdown' ~ random(10000)) %} {% set _dyanmic_active = dynamic_active|default(false) %} {% if attributes is empty %}