- πΊπΈUnited States scotwith1t Birmingham, AL
Incredibly important patch for anyone using the USWDS framework and many others. Thanks @heddn and others! Not sure what else is needed to get this to land, other than passing tests, but hope to see this one in a release soon! :)
- last update
almost 2 years ago 28,325 pass, 16 fail - last update
almost 2 years ago 28,302 pass, 18 fail - πΊπΈUnited States scotwith1t Birmingham, AL
Just an additional note that this has a side effect of changing how
clean_class
twig filter works. For example, we had a block which had:{% set classes = [ 'block', 'block-' ~ configuration.provider|clean_class, 'block-' ~ plugin_id|clean_class, ] %}
Previously, the plugin_id had its : stripped out and the css was written and applied to that class. After this post, the class name changed because
clean_class
no longer stripped that out. Not a huge deal, but something I hadn't anticipated and had to do a (very minor) css update to address. I would assume there could be other unexpected side effects for other places/modules that use thecleanCssIdentifier
method of this class. - π§π¬Bulgaria nikolabintev
I am uploading a patch that can be applied to the latest stable Drupal 10 version: 10.2.4
- πΊπΈUnited States liberatr Portland, OR
The patch in #46 removes the comment that mentions period:
// - the period (U+002E)
It is still present in regex, just not in comment.
- πΊπΈUnited States sea2709 Texas
IMHO, I agree that we should allow more characters in CSS classes like Tailwind CSS classes with colon, brackets, etc.
I'm concerned when we makes changes for the functioncleanCssIdentifier
, since this function is used to clean the classes generating by Drupal.For example, I place a field block in layout builder, that field block has a class like
block-field-block:paragraph:grid:field-column
if we allow colon incleanCssIdentifier
I wonder if generated classes should have colons, and it might impact an existing site which has many elements being styled based on the generated classes. We should think twice before applying changes for
cleanCssIdentifier
. - πΊπΈUnited States Chris Burge
@sea2709 - That's exactly the issue. We can't change
Html::cleanCssIdentifier
without causing CSS bugs.#13
I'm wondering if the best way to solve this issue is to use a configuration flag/setting similar to the $conf['allow_css_double_underscores'] setting in D7 that allowed BEM double underscore CSS selectors.
I think the behavior should be configurable. Maybe a $setting to define additional characters?
- π§πͺBelgium yazzbe
> I think the behavior should be configurable. Maybe a $setting to define additional characters?
That is a great idea!
Just like in the block_class module where it is also configurable to allow special characters in classes.
- πΊπΈUnited States liberatr Portland, OR
Rerolled the 10.3 patch from #46 to include the missing comment.
- πΊπΈUnited States ibbwebguy
I believe the order of unicode characters is wrong and will result in unwanted characters being valid. The correct order should be:
$identifier = preg_replace('/[^\x{002D}\x{002E}\x{002F}\x{0030}-\x{0039}\x{003A}\x{0040}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $identifier);
Alternately, the syntax could be shortened to the following, but then the alphanumeric ranges would not be specifically listed.
$identifier = preg_replace('/[^\x{002D}-\x{003A}\x{0040}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $identifier);
- πΊπΈUnited States ibbwebguy
Rerolled the 10.3 patch from #51 to include the correct unicode regex.