Problem/Motivation

The removal of Classy as base theme in 3.x also results in the removal of most classes, so that for example inline field labels don't display inline.

Users can set the display of the field label to be "Above", "Inline", "- Hidden -" or "- Visually Hidden -". In version 3.0.0-rc1 of this theme, setting it to "Inline" has no effect. This worked in version 2.0.6. See screenshot below.

Screenshot

This is then breaking a built-in Drupal behaviour.

Steps to reproduce

Have a content type with some fields. Set the label for at least one of them to "Inline". Observe that this has no effect.

Proposed resolution

I suspect this is because the classes field__label and field__item are missing from the 3.0.x version. Inspecting the markup I get:

Bootstrap5 ver. 2.0.6:

<div class="field__label">Shortname</div>
<div class="field__item">advanced_help</div>

This is also the markup up field label and item I get with the core Olivero theme.

Bootstrap5 ver. 3.0.0-RC1:

<div>Shortname</div>
<div>advanced_help</div>

Restore these classes.

CommentFileSizeAuthor
#13 after fix.png105.06 KBjannakha
#13 before fix.png93.01 KBjannakha
bs5field.png6.44 KBgisle

Issue fork bootstrap5-3333397

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

gisle created an issue. See original summary.

ressa’s picture

Title: Regression: Inline field labels don't display inline » Regression: Most classes are missing after Classy was removed as base theme
Version: 3.0.0-rc1 » 3.0.x-dev
Priority: Normal » Major
Issue summary: View changes
Related issues: +#3331443: Add required SCSS/CSS fixes after removal of Classy and Stable

It looks like most classes are missing, after the removal of Classy as base theme. In Drupal 9, the classes are back, and everything looks fine, if I in bootstrap5.info.yml change
base theme: false
to
base theme: classy

This won't work in Drupal 10, since Classy theme is deprecated and has been removed.

I think the cause is the same in #3333424: Regression: Gutters are zero width, which perhaps can be closed as a duplicate?

ressa’s picture

I found an issue (#3329904: Classy theme is deprecated in Drupal 9.5 and will be removed in Drupal 10) about the same challenge, where @davedg629 suggests restoring Classy as base theme. He quotes the Classy project page, which says:

We do not recommend new projects use this theme, but this existing projects that depend on Classy may use this for Drupal 10+ and it should work no differently than if it were using the Drupal core Classy.

To prepare for migration, this can be safely installed in a version of Drupal with Classy still in core, be it Drupal 9 or a Drupal 10 branch where Classy hasn't yet been removed. If the two themes are present, there won't be a conflict, and Drupal will automatically use the version in the core/ directory.

I tested this by restoring Classy as a base theme and dependency in bootstrap5.info.yml, downloaded and enabled it, and it seems to work in both Drupal 9 and Drupal 10, where the missing classes are restored.

I created a patch as a proof of concept, but am not sure if testing the downloading of it and the required theme Classy with Composer is possible ... probably not. For manual testing, apply the patch and then:

composer require drupal/classy
drush theme:install classy
vladimiraus’s picture

Thanks for the commit. 🥂
We can't reply on classy support moving forward.

We need to start updating SCSS/CSS without reliance on Classy.
Please introduce CSS issues separately with screenshots.
Parent issue with instructions: #3331443: Add required SCSS/CSS fixes after removal of Classy and Stable

ressa’s picture

Status: Needs work » Needs review

Could we use Starterkit theme as base theme instead? I have updated the patch, and after enabling the Starterkit theme and clearing caches, the classes are back:

drush theme:install starterkit_theme

vladimiraus’s picture

Status: Needs review » Needs work

@ressa - don't think it is a good idea to enable starterkit.
It is hidden for a reason.
Maybe better try to generate new starterkit theme and see what's the difference?

vladimiraus’s picture

So I generated theme using starterkit.
It copies bunch of css and templates as well as defined some libraries.
So I copied

  • all css component files
  • block templates
  • library definitions

I also added stable9 as base theme.

Check out my merge request.
Don't forget to run ./vendor/bin/drush -l default theme:install stable9

I think it might be a good start.

ressa’s picture

Thanks @VladimirAus, though it doesn't fix this issue, as far as I can tell ...

Just before your MR, I added a smaller MR !26, which just adds a Twig-file for field and the CSS. I had a look to see where the classes come from, which were these two files. They are identical in both Classy and Starterkit themes, as can be seen by the empty diff results:

$ grep -liR "field__label"
templates/field/field.html.twig
css/components/field.css

$ diff classy/css/components/field.css starterkit_theme/css/components/field.css
$ diff classy/templates/field/field.html.twig starterkit_theme/templates/field/field.html.twig 
$ 

I added the two files in the patch, and registered the CSS file in bootstrap5.libraries.yml.

There are many more twig-files in a fresh Starterkit (85) compared to Bootstrap5 (29):

Bootstrap5 (after adding field.html.twig template):

$ tree web/themes/contrib/bootstrap5/templates/
[...]
9 directories, 29 files

A default Starterkit theme:

$ tree web/themes/my_machine_name/templates/
[...]
11 directories, 85 files

So we probably need to figure out which of these 85 Twig-files need to be added ... or just add all of them, in one fell swoop?

vladimiraus’s picture

Status: Needs work » Needs review

@ressa I moved all the templates from starterkit and fixed most of teh issues.
Please let me knwo if it fixes yours.

vladimiraus’s picture

Few additional fixes.

jannakha’s picture

StatusFileSize
new93.01 KB
new105.06 KB

Templates have been created as a part of this MR:
- templates set classes for entity's HTML, eg node-* field-*
- these classes are used to apply styles

Ready to merge

jannakha’s picture

Status: Needs review » Reviewed & tested by the community

updated status after review (see prev comment)

  • VladimirAus committed 736244a3 on 3.0.x
    Issue #3333397 by ressa, VladimirAus, jannakha, gisle: Regression: Most...
vladimiraus’s picture

Status: Reviewed & tested by the community » Fixed

Thank you! Committed! 🥂
In the end added final check on update hook.

vladimiraus’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.