From e4c5c64087f78ad9145706e2beec433c8db3956e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikel=20Mart=C3=ADn?= Date: Mon, 1 Sep 2025 14:36:47 +0200 Subject: [PATCH] MDL-85990 core: Improve core/toggle to accept any attribute Improve the core/toggle template, so it can accept any attribute and not only starting with "data-". This will allow to add attributes like "aria-label", for example. --- .upgradenotes/MDL-86990-2025091206232119.yml | 7 +++++++ .../content/moodle/components/toggle.md | 10 +++++----- public/lib/templates/toggle.mustache | 8 +++++--- .../forum/classes/courseformat/overview.php | 20 +++++++++---------- .../course_external_tools_list.php | 10 +++++----- .../local/systemreports/report_schedules.php | 8 ++++---- 6 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 .upgradenotes/MDL-86990-2025091206232119.yml diff --git a/.upgradenotes/MDL-86990-2025091206232119.yml b/.upgradenotes/MDL-86990-2025091206232119.yml new file mode 100644 index 00000000000..b3b1ab9df0d --- /dev/null +++ b/.upgradenotes/MDL-86990-2025091206232119.yml @@ -0,0 +1,7 @@ +issueNumber: MDL-86990 +notes: + core: + - message: >- + In toggle.mustache `dataattributes` parameter is deprecated. Use + `extraattributes` instead + type: deprecated diff --git a/public/admin/tool/componentlibrary/content/moodle/components/toggle.md b/public/admin/tool/componentlibrary/content/moodle/components/toggle.md index 0a506dd5d21..10d989e542d 100644 --- a/public/admin/tool/componentlibrary/content/moodle/components/toggle.md +++ b/public/admin/tool/componentlibrary/content/moodle/components/toggle.md @@ -18,7 +18,7 @@ The parameters for the template context are: * extraclasses: Any extra classes added to the toggle input outer container. * checked: If the initial status is checked. * disabled: If toggle input is disabled. -* dataattributes: Array of name/value elements added as data-attributes. +* extraattributes: Array of name/value elements added as attributes. * title: Title text. * label: Label text. * labelclasses: Any extra classes added to the label container. @@ -32,8 +32,8 @@ Checked toggle and with "visually-hidden" label. { "id": "example-toggle-1", "checked": true, - "dataattributes": [{ - "name": "action", + "extraattributes": [{ + "name": "data-action", "value": "toggle-status" }], "title": "Toggle Enabled", @@ -50,8 +50,8 @@ Disabled toggle with extra classes. "id": "example-toggle-2", "disabled": true, "extraclasses": "mt-2 ms-2", - "dataattributes": [{ - "name": "action", + "extraattributes": [{ + "name": "data-action", "value": "toggle-status" }], "title": "Toggle Disabled", diff --git a/public/lib/templates/toggle.mustache b/public/lib/templates/toggle.mustache index 20e35be5665..6a2c18af033 100644 --- a/public/lib/templates/toggle.mustache +++ b/public/lib/templates/toggle.mustache @@ -24,8 +24,8 @@ "id": "reality-toggle-3", "checked": true, "disabled": false, - "dataattributes": [{ - "name": "action", + "extraattributes": [{ + "name": "data-action", "value": "toggle-reality" }], "title": "Title example", @@ -37,9 +37,11 @@
{{$labelmarkup}}