Here's the correct file as a patch
Per Fonts API documentation when no additional paramenter is provided to the fontsapi URL, the default configuration for each axis, with weight at 400, optical size at 48, grade at 0 and fill (also 0.) is requested.
When the Material symbols change was added to the module, the fonts were requested with all possible variations filter :opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200
this is why the size increased a lot.
If we follow that standard that we already have in the module, the other fonts that were already present in the module, the correct approach would be to load the fonts without any additional filter.
Here's a patch where I've changed the fonts to be loaded without any additional filters.
This patch applies to all fonts, but as example the Material Symbols Rounded was reduced from 4.5mb to 387kb
Here's the #39 patch with the loading attribute that was missing
Patch #151 worked for me:
Drupal: 10.1.1
PHP: 8.1.14
Before Patch
Views Configuration
HTML
After Patch
Views Configuration
HTML with config enabled
HTML with config disabled
Patches #15 and #17 work as expected, but the login form has a Permanent cache so when the cache was enabled to destination parameter was not being set correctly.
So I've created an MR to include patches #15 and #17 but also add the destination parameter in the Login Form cache context
gabriel.passarelli β made their first commit to this issueβs fork.
I've created an MR that adds grid-row and grid-column attributes for the .layout-node-form elements.
Before the changes
After the changes
gabriel.passarelli β created an issue.
I was able to make #73 work, but I had to add a custom code to my JS scripts. And the reason for this is that the patch on #73 fires an event,drupalAjaxFormValidate
and will wait for the result of that event in order to check if it should trigger the AJAX submit or not, but it does not trigger the native browser form validation.
So I had to implement my own code for this event and trigger the native browser validation.
Drupal.behaviors.clientSideValidationAjax = {
attach(context) {
$(context).on("drupalAjaxFormValidate", (event) => {
const form = $(event.target).closest("form")[0];
if (!form.checkValidity()) {
// This is the magic function that displays the validation errors to the user
form.reportValidity();
return false;
}
return true;
});
},
};
It's also important to highlight that if you have any additional #ajax
to the form, that you don't want to trigger the native validation when that AJAX is performed, you need to add a formnovalidate
attribute to your field definition in the form api. Like this:
$form['select_with_ajax'] = [
'#type' => 'select',
...
'#attributes' => [
'formnovalidate' => "formnovalidate",
],
'#ajax' => [
'callback' => '::ajaxWithoutNativeValidation',
],
];
gabriel.passarelli β created an issue.
I was able to make #73 work, but I had to add a custom code to my JS scripts. And the reason for this is that the patch on #73 fires an event,drupalAjaxFormValidate
and will wait for the result of that event in order to check if it should trigger the AJAX submit or not, but it does not trigger the native browser form validation.
So I had to implement my own code for this event and trigger the native browser validation.
Drupal.behaviors.clientSideValidationAjax = {
attach(context) {
$(context).on("drupalAjaxFormValidate", (event) => {
const form = $(event.target).closest("form")[0];
if (!form.checkValidity()) {
// This is the magic function that displays the validation errors to the user
form.reportValidity();
return false;
}
return true;
});
},
};
It's also important to highlight that if you have any additional #ajax
to the form, that you don't want to trigger the native validation when that AJAX is performed, you need to add a formnovalidate
attribute to your field definition in the form api. Like this:
$form['select_with_ajax'] = [
'#type' => 'select',
...
'#attributes' => [
'formnovalidate' => "formnovalidate",
],
'#ajax' => [
'callback' => '::ajaxWithoutNativeValidation',
],
];
gabriel.passarelli β created an issue.