Problem/Motivation

Discovered in #3066006: Convert Views UI to new design system.

If there is a select input in a table, its width is not factored into determining column width and can result in what is seen in the lower right of this group of screenshots.

Note that this is not a problem in views as a recent redesign addressed it there.

Proposed resolution

Probably change the style in tables.pcss.css that is causing this

td > .form-item > .form-element,
td > .ajax-new-content > .form-item > .form-element {
  width: 100%;
}

Steps to reproduce

Go to en/admin/structure/types/manage/page/display
Click "show row weights" if they're not already being shown.
Narrow the viewport until you see this thing:

User interface changes

API changes

Data model changes

Release notes snippet

Issue fork drupal-3135457

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

bnjmnm created an issue. See original summary.

bnjmnm’s picture

Issue summary: View changes
pradeepjha’s picture

Assigned: Unassigned » pradeepjha
pradeepjha’s picture

We can change width as auto for form-element of Claro theme table component. That will help select field to stretch based on it's select options.

Testing Steps:

  • Go to any view settings which has table format. Or create a new view with table format.
  • Check select list value. It shouldn't be cropped.
  • All select list value should display properly on all devices.
  • Also check attached image for reference.
pradeepjha’s picture

Assigned: pradeepjha » Unassigned
Status: Active » Needs review
bnjmnm’s picture

Status: Needs review » Needs work
StatusFileSize
new56.96 KB
new58.83 KB

Thanks for the patch! I think this is close but noticed something:

+++ b/core/themes/claro/css/components/tables.css
@@ -264,7 +264,7 @@ td.is-active {
 td > .form-item > .form-element,
 td > .ajax-new-content > .form-item > .form-element {
-  width: 100%;
+  width: auto;
 }

While this fixes the issue with select elements, it also leads to a regression.
Without the patch, width 100%

With the patch, width auto

I imagine this can be addressed by creating a style more targeted to select elements since td > .form-item > .form-element impacts many elements that aren't part of the reported issue.

pradeepjha’s picture

Assigned: Unassigned » pradeepjha
pradeepjha’s picture

Assigned: pradeepjha » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.12 KB

Thanks. Updated patch. Made change more specific to select element.

KondratievaS’s picture

StatusFileSize
new107.27 KB

Tested patch from #8. Select width are ok now, but buttons are too big now, which was not the case before - probably regression

bug

KondratievaS’s picture

Status: Needs review » Needs work
pradeepjha’s picture

Status: Needs work » Needs review
StatusFileSize
new71.61 KB
new55.86 KB

Thanks for your feedback @KondratievaS. We have also faced same issue but not in incognito window of browser. It's might be your browser cache. Please clear your browser cache and then test it again.

KondratievaS’s picture

Thanks for your comment @pradeepjha. You are right - can not reproduce this bug anymore

KondratievaS’s picture

Status: Needs review » Reviewed & tested by the community
xjm’s picture

Thanks for working on this issue!

Tagging for frontend committer review.

lauriii’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs frontend framework manager review
+++ b/core/themes/claro/css/components/tables.pcss.css
@@ -183,6 +183,11 @@ td > .ajax-new-content > .form-item > .form-element {
+td > .form-item > .form-element--type-select {

Is there a particular reason the select element has to be strictly at the root of the cell? Could we just target td .form-element--type-select?

bnjmnm’s picture

Status: Needs review » Needs work

Setting to Needs Work for #15This can get either for a patch update or a comment explaining why a change isn't needed.

kiran.kadam911’s picture

Assigned: Unassigned » kiran.kadam911
kiran.kadam911’s picture

Assigned: kiran.kadam911 » Unassigned
Status: Needs work » Needs review
StatusFileSize
new438.71 KB
new444.93 KB
new1.25 KB
new963 bytes

@lauriii @bnjmnm For #15 targeted select element using child selector I think @pradeepjha used same implementation as per previous for select like below from existing code which is good to go,

td > .form-item > .form-element,
td > .ajax-new-content > .form-item > .form-element

And If we directly target form elements inside TD like below,

+++ b/core/themes/claro/css/components/tables.pcss.css
@@ -179,13 +179,13 @@
  * Target every .form-element input that parent is a form-item of a table cell.
  * This ignores the filter format select of the textarea editor.
  */
-td > .form-item > .form-element,
-td > .ajax-new-content > .form-item > .form-element {
+td .form-element,
+td .ajax-new-content .form-element {
   width: 100%;
 }
 
 /* Force browsers to take auto width for 'select' element. */
-td > .form-item > .form-element--type-select {
+td .form-element--type-select {
   width: auto;
 }

It will target all form elements (input, select, etc.) inside TD & break other form elements that are nested. See the below-attached screenshot. Example from /admin/structure/types/manage/article/form-display widget and it's settings from icon.

In my opinion, we should go head with the child selector approach(td > .form-item > .form-element--type-select), Feel free to add your opinion.

Minor update in the patch related to select element, Kindly review.

Thanks!

Status: Needs review » Needs work

The last submitted patch, 18: 3135457-18.patch, failed testing. View results

kiran.kadam911’s picture

Status: Needs work » Needs review
tanubansal’s picture

After adding a latest patch, select list width is appearing as expected on all the browsers and devices.
This can be moved to RTBC

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

ckrina’s picture

Issue summary: View changes
StatusFileSize
new112.61 KB

Is there a particular reason the select element has to be strictly at the root of the cell? Could we just target td .form-element--type-select?

Re #15:
I think the key point is having 100% set on all form elements. It does look better on a visual perspective, but it’s overriding a feature that gives clues to the user about how much content is expected to be filled. So UI is breaking UX. I'd say setting width: auto (or removing it entirely, not sure about the code) gives this control back to whoever is defining the form.
A clear example is with smaller fields inside a multiple field: (thanks @slv_ for the screenshot and rising the issue!)

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sakthivel m’s picture

StatusFileSize
new1.25 KB

#25 Just Re-roll the patch

chetanbharambe’s picture

Assigned: Unassigned » chetanbharambe
chetanbharambe’s picture

StatusFileSize
new352.86 KB
new177.28 KB
new160.29 KB
new156.1 KB

This issue I am not able to reporoduciable on 9.3.x version
Working as Expected.

Testing Steps:
# Goto: admin/appearance -> Apply Claro theme
# Goto: http://drupal9-3.dd:8083/en/admin/structure/views/view/comment
# Click on Settings under Format
# Check the width in table

Looks good to me.
Please find attached screenshots.

chetanbharambe’s picture

Assigned: chetanbharambe » Unassigned
bnjmnm’s picture

Issue summary: View changes
StatusFileSize
new70.91 KB

Re not being able to reproduce in #27
This is fixed in views, but it is still a problem elsewhere. Using the inspector to search for td > .form-item > .form-element will show the style documented as causing the issue is now overridden in views.

Forms such as the node display UI still show the issue. Steps to reproduce have been added to the issue summary.

sakthivel m’s picture

StatusFileSize
new5.72 KB

#30 Please review the patch

Status: Needs review » Needs work

The last submitted patch, 30: 3135457.30.patch, failed testing. View results

sakthivel m’s picture

Status: Needs work » Needs review
bnjmnm’s picture

+++ b/core/themes/claro/css/components/tables.pcss.css
@@ -243,3 +249,9 @@ td.priority-medium {
diff --git a/core/themes/claro/templates/classy/dataset/table.html.twig b/core/themes/claro/templates/classy/dataset/table.html.twig

diff --git a/core/themes/claro/templates/classy/dataset/table.html.twig b/core/themes/claro/templates/classy/dataset/table.html.twig
index 2afa9c1556..ebcdfe1a3e 100644

index 2afa9c1556..ebcdfe1a3e 100644
--- a/core/themes/claro/templates/classy/dataset/table.html.twig

--- a/core/themes/claro/templates/classy/dataset/table.html.twig
+++ b/core/themes/claro/templates/classy/dataset/table.html.twig

+++ b/core/themes/claro/templates/classy/dataset/table.html.twig
+++ b/core/themes/claro/templates/classy/dataset/table.html.twig
@@ -39,75 +39,77 @@

The most recent patch added a file from an unrelated issue. There aren't any changes related to this issue, so I opened a merge request based on the prior patch you provided, and this issue can continue working with the merge request instead of patches.

bnjmnm’s picture

Issue #3205412: Form element in tables is not readable on mobile was created as a duplicate of this, and it has essentially the same solution, but it may be worth crediting the contributors on that issue since they were not aware they were duplicating the work here.

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

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kristen pol’s picture

Issue tags: +Bug Smash Initiative

Seems to be a duplicate of #3159896: Select form field values are hidden at narrow screen widths in Claro theme but I haven't compared the patches.

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

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now 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.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now 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.

lauriii’s picture

Status: Needs review » Closed (duplicate)