Problem/Motivation

In #3151119: Text field with multiple values overflows on narrow screens a width:100% was added for text fields inside tables in the seven theme. This makes that text fields always take the full width of the tabel (in multiple elements).
This however ignores the size attribute of those elements.

Steps to reproduce

Create multiple text field.
On edit form see it takes full width.
Change size in form display settings.
Note that the text field is always full width.

Disabling the width:100% line (in dev tools) does take the size attribute correctly into account, but that then would reintroduce the other problem.

Comments

mallezie created an issue. See original summary.

katrienc’s picture

Status: Active » Needs review
StatusFileSize
new391 bytes

a possible solution to this is to add a max-width

td > .form-item > .form-text,
td > .ajax-new-content > .form-item > .form-text {
  width: 100%;
  max-width: 100%;
}
katrienc’s picture

StatusFileSize
new480 bytes

ok, this only will work off course when the parent is an inline-block element

vikashsoni’s picture

StatusFileSize
new31.89 KB
new12.58 KB

Patch working fine after patch we able to reduce size for ref sharing screenshot....

chetanbharambe’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new297.58 KB
new70.37 KB
new317.53 KB

Verified and tested patch #3.
Patch applied successfully and looks good to me.

Testing Steps:
# Goto: Admin -> Structure -> Content types -> Click on manage field and add text field
# Add respective content type
# See the fields
# Goto: admin/structure/types/manage/article/form-display
# Change the size
# Note that the text field is always in full width

Expected Results:
# The text field should be as per size which the user sets in the form display setting.

Actual Results:
# The text field is always in full width.

Please refer attached screenshots.
Looks good to me.
Can be a move to RTBC.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review

Would it be better to revert the change from #3151119: Text field with multiple values overflows on narrow screens and instead just set a max-width

gauravvvv’s picture

StatusFileSize
new491 bytes
new402 bytes

Patch updated, Attached interdiff for patch #3, #7.
Please review.

alexverb’s picture

StatusFileSize
new15.17 KB

With this patch the text field does not seem to resize to the width of it's container when resizing to a width smaller than the textfield size. Unless you go below 600px then form.css:306 puts text fields back to 100% while bigger screen sizes are already set to max-width by form.css.

I also think the initial fix to put it on 100% was incorrect. But I don't know how to ensure that it resizes to the width of the container when going smaller. My guess is that this is an effect of the drag and drop tables as other text fields do not seem to behave that way.

alexverb’s picture

Status: Needs review » Needs work

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.

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.

Harish1688’s picture

StatusFileSize
new586.66 KB

Tested the bug not found the issue in (9.4.x-dev to 9.5.x-dev) textfield takes the value and working fine, without any patch.
Every patch use this property (max-width: 100%;), but this property added in the form.css to resolve this.

longwave’s picture

Component: Seven theme » Claro theme

The Seven theme has been removed from Drupal 10 core. However, I confirmed that this issue also affects Claro - text fields with multiple values ignore the "Textfield size" option set in manage form display, so moving this to Claro for further discussion in core.

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.

Version: 10.1.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, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

akhil babu’s picture

I tried to recreate this issue in claro theme
Steps followed

  • Added a text field to article content type. Set cardinality as 'Unlimited'
  • Default value of 'Size of textfield' is 60 in manage form display
  • Content -> Add content -> Article

\
Output

  • Textfield takes 100% width of parent. But no overflow or breaking

Only local images are allowed.

  • Edited manage form display and changed Size of textfield to 100

Output
Same as previous case.

  • Decreased Size of textfield to 30 (Half of default value)

Output

  • Expected the width to decrease by 50%. The width of the textfield did decrease; however, the difference is very small.

Only local images are allowed.

  • Changed Size of textfield to 30 (1/6th of default value)

Output

  • The width of the textfield did decrease again but the difference is very small

Only local images are allowed.

Not sure how the width is supposed to change based on the textfield size. However, I believe the current behavior is not correct.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.