Problem/Motivation

Views exposed filters that use autocomplete are more than twice as wide as plain text filters:

As @larowlan pointed out in #15, autocomplete fields are larger for a reason so you have space to read the results that appear.

Proposed resolution

Set the default size to be smaller?

OR

Make them configurable?

Remaining tasks

Decide what to do.

User interface changes

Original issue summary
---

In a fresh install of Drupal 8.8.5, when adding an exposed filter using the criteria of "Has taxonomy term", the field is twice as wide as all other fields that are exposed. I have attached images. The default character length in most text based fields is 30 but in "has taxonomy term" it is set at 60. This makes the filter region look like ... you know.

I know I have to find a way to make a sub theme just to fix that one little item, but the more I thought about it is a minor bug and one that is easily fixed in Core.

See attached files

Comments

joaomachado created an issue. See original summary.

joaomachado’s picture

Issue summary: View changes
raunak.singh’s picture

Assigned: Unassigned » raunak.singh
raunak.singh’s picture

Assigned: raunak.singh » Unassigned
Status: Active » Needs review
StatusFileSize
new515 bytes
new74.07 KB
new62.06 KB

Hi @joaomachado,

I have added a patch on this ticket and attached screenshot also please take a look and let me know if there is any issue.

Status: Needs review » Needs work
raunak.singh’s picture

Assigned: Unassigned » raunak.singh
raunak.singh’s picture

Assigned: raunak.singh » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.38 KB

Updated test cases in the patch.

sharma.amitt16’s picture

patch applied successfully on my machine.

~/Sites/drupal-9.0.0-beta2(9.1.x*) » git apply ~/Downloads/patches/views-exposed-filter-auto-complete-has-taxonomy-term-field-too-wide-3135137-7.patch                             amitsharma@MacBook-Pro-2
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/Sites/drupal-9.0.0-beta2(9.1.x*) »                                                                                                                                               

It looks good now on my local machine.

I feel we can move it to RTBC.

sharma.amitt16’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new213.02 KB
joaomachado’s picture

StatusFileSize
new34.83 KB
new80.35 KB

Well I seem to have an issue with applying the patch using composer see attached images. But I manually ran the patch using "patch -p1" it it say it patched it with no errors, but nothing changes... Don't know what to do.

Composer error
Only local images are allowed.

raunak.singh’s picture

Hi @joaomachado

Please go to your project root folder and run this command: curl https://www.drupal.org/files/issues/2020-05-14/views-exposed-filter-auto... | git apply -v

Let me know if there is any issue

joaomachado’s picture

@Raunak.singh That worked, looks great now! I would say it is a winner.

Version: 8.8.5 » 8.8.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

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.

larowlan’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -views exposed filters +Needs screenshots, +Bug Smash Initiative

Reviewed this as part of Bug Smash Initiative.

Can we get a before screenshot of the field, relative to other fields in an exposed form.

Also, this is an autocomplete field, so is larger for a reason.

So perhaps this should be a feature request to make the size configurable?

larowlan’s picture

Can someone do some git sleuth work 🔎 to work out when this was made 'size => 60' to see if it was by design.

If so, we need to make this a feature request to make it configurable rather than reverse that change.

lendude’s picture

Status: Needs review » Needs work
--- a/core/lib/Drupal/Core/Render/Element/Textfield.php
+++ b/core/lib/Drupal/Core/Render/Element/Textfield.php

@@ -51,7 +51,7 @@ public function getInfo() {
-      '#size' => 60,
+      '#size' => 30,

Changing this in the base TextField is not the right fix for something in Views....

pameeela’s picture

Title: Views Exposed Filter Auto Complete "Has taxonomy term" field too wide » Views exposed filters with autocomplete are much wider than text filters
Issue summary: View changes
Issue tags: -Needs screenshots
StatusFileSize
new7.36 KB

Added a screenshot, and updated title/IS.

It is indeed larger, but this applies to all autocomplete filters, not just taxonomy. The same is true for all autocomplete fields throughout core - when adding a menu link, redirect, URL on link field etc.

I don't know if this is a bug, lots of things in core have defaults that require a theme to override and it's not broken in any way, it's just a bit large.

Not sure whether we could make the change to apply *only* to views exposed filter fields, but certainly I would be opposed to changing it in the other places, like menu links and link fields, where often the extra space is necessary.

rishabhthakur’s picture

Assigned: Unassigned » rishabhthakur

Work on this..

rishabhthakur’s picture

Assigned: rishabhthakur » Unassigned
Status: Needs work » Needs review
StatusFileSize
new42.59 KB
new11.23 KB
new696 bytes
new1.59 KB

@larowlan as it's a bit wider as compare to title fields
and also if we will give Exposed form option config fields to manage field size, but on its process before rendering fields, and then core #process_default_value will modify as per Render FormElement.
So, we can achieve it by modifying autocomplete field size on before render of expose form fields.
@pameeela I have added code snippet with 'template_preprocess_views_exposed_form' to prevent changes in other places, like menu links and link fields.

I have attached Screenshot after applying patch file on local

Status: Needs review » Needs work

The last submitted patch, 20: Views-exposed-filters-with-autocomplete-are-much-wider-than-text-filters-3135137-20.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

rishabhthakur’s picture

Re check with code fix

rishabhthakur’s picture

Status: Needs work » Needs review
lendude’s picture

I think I'm -1 on fixing this.

On existing sites this might break the layout they currently have, and adding an opt-in setting for this would add a new setting to Views that we can really do without.

I understand the reasoning behind this, and having a consistent layout is nice, but I don't think this is worth possible BC breaks.

joaomachado’s picture

@Lendude, so your logic is to keep allowing new sites to be broken? I am not understanding this, the layout is already broken.

joaomachado’s picture

StatusFileSize
new23.83 KB
new92.77 KB

I am wondering what the status is on this issue, is it considered "works as designed"?

At any rate, as @Lendude stated in his comment above, this could potentially brake existing sites that have put in counter-measures for this, and I totally understand his reluctance to make a change and I am not discounting that position at all. But consider this, I chose Drupal because it was a Mobile friendly CMS, I wanted to build a site that had the absolute minimal dev and testing modules, even to use only the Bartik theme, in this way I would make the site more "upgradeable" for the future, including major versions of Drupal itself. The home page was to be a views search page.

So a new site, that adds Taxonomy Terms and exposes the search field to autocomplete will get this when it is viewed on mobile device;
Mobile1

Mobile1

Is this is considered "Working as designed"?

pameeela’s picture

@joaomachado the specific issue you’ve raised that the field is breaking smaller layouts is a genuine bug I think, it’s just not exactly what the original issue was about.

If we are saying the original issue won’t be addressed we can probably update this one to be about the display on smaller screens. Or could make a separate issue for that.

pameeela’s picture

I've created #3192254: Views autocomplete input is too wide on mobile to address the CSS issue, as it only seems to be occurring in Bartik. The original request of this issue was for a much larger change in how this input displays, I think we can fix the CSS bug much more easily.

joaomachado’s picture

Thanks, then I suppose there are two issues... but they are the same. They both look ugly if not addressed. So why not apply the CSS to the both?

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.

smustgrave’s picture

Status: Needs review » Needs work
Issue tags: +Needs Review Queue Initiative, +Needs tests, +Needs screenshots

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

Confirmed this issue on D10 by adding an authored by field to the content view.
Think we will need test to show this issue (but don't know what that would be)
Readding the screenshot tag for D10 before/after

Also think instead of $form[$key we can just use $element.

_utsavsharma’s picture

StatusFileSize
new672 bytes
new672 bytes

Patch for 10.1.x.
used $element instead of $form[$key

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.

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.