In the Format settings, I have two fields set to align right. However, if I turn off "Add default classes" for style settings at the field level, the alignment doesn't work for the field data, though it does still apply to the column heading. See example screenshot.

It may be argued that when turning off "Add default classes", this class really should *not* be added, but I think this class should not be included in the "defaults" as it is due to a setting that is selected specifically for the view, not generic default classes that views generates. We don't want all the extra classes in the markup of our pages, but we do want to be able to control justification.

UPDATE: The following copied from comment #13, as requested.

In this one, see the circled "Settings" option.

image-a

This is the form shown when you click "Settings". The alignment setting circled in red is how we right-justify numeric columns.

image-b

And in the "Fields" section, I clicked on "Field Collection Item: Quantity". The "Add default classes" setting is the one I referred to in my original post. Note that we had to leave that set on all fields in the site because of this issue.

image-c

With the settings as they are shown in the above screenshots, here's the rendered HTML. One thing I hadn't noticed before is that the "views-align-right" class is added twice on the column heading (red arrows). And, as you can see, it is also on the quantity field in the detail row (yellow underscore).

image-d

Then with the alignment setting for the quantity field still set to "Right", I unchecked its "Add default classes" setting. This is the rendered HTML with those settings.

image-e3

Things to note there...

  1. One of the duplicated "views-align-right" classes has been removed from the column heading for that field, and that class has also been removed from the field (td).
  2. The default field classes were not actually removed from the quantity field. Instead, it appears that the classes for that field have been duplicated from the previous field ("position_year") - see the yellow underscores.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ExTexan created an issue. See original summary.

Lendude’s picture

Title: Field justfication not on field if views default classes disabled » Field justification class not on field if views default classes disabled
Project: Views (for Drupal 7) » Drupal core
Version: 8.x-3.x-dev » 8.3.x-dev
Component: table style » views.module

Moving to the right queue.

@ExTexan I would be inclined to agree that these are to separate things. Would have to look at the underlying code if there are any other reasons these two things are connected.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

Status: Active » Postponed (maintainer needs more info)
Issue tags: +Bug Smash Initiative, +Needs steps to reproduce

Can you provide some steps to reproduce here.

I'm not sure which format settings you're referring to.

ExTexan’s picture

FileSize
225.56 KB
75.71 KB
118.31 KB
42.15 KB
212.5 KB

Perhaps a series of screenshots would help...

In this one, see the circled "Settings" option.
image-a

This is the form shown when you click on "Settings". The alignment setting circled in red is how we right-justify numeric columns.
image-b

And in the "Fields" section, I clicked on "Field Collection Item: Quantity".
The "Add default classes" setting is the one I referred to in my original post. Note that we had to leave that set on all fields in the site because of this issue.
image-c

With the settings as they are shown in the above screenshots, here's the rendered HTML.
One thing I hadn't noticed before is that the "views-align-right" class is added twice on the column heading (red arrows).
And, as you can see, it is also on the quantity field in the detail row (yellow underscore).
image-d

Then with the alignment setting for the quantity field still set to "Right", I unchecked its "Add default classes" setting.
This is the rendered HTML with those settings.
image-e3

Things to note there...

  1. One of the duplicated "views-align-right" classes has been removed from the column heading for that field, and that class has also been removed from the field (td).
  2. The default field classes were not actually removed from the quantity field. Instead, it appears that the classes for that field have been duplicated from the previous field ("position_year") - see the yellow underscores.
smustgrave’s picture

Status: Postponed (maintainer needs more info) » Active
Issue tags: +Needs issue summary update

Can confirm this issue on 11.x

Can the issue summary be updated with the steps written out like above.

ExTexan’s picture

Issue summary: View changes

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.