Hardcoded "width" of chosen-container moves field outside of mobile viewport

Created on 2 September 2024, 16 days ago
Updated 17 September 2024, 1 day ago

Problem/Motivation

The chosen-container seems to hardcode a width of 500px. This is larger than the browsers viewport and makes the field moving outside of visble area.

Tested with Oliviero theme on D10.3.2

Steps to reproduce

  1. Add chosen field to content type
  2. Add content with mobile phone or make your browser window small.
  3. chosen-container is larger then the screen.

Proposed resolution

Make the field dynamic in size so it works on all screen sizes.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

4.0

Component

Code

Created by

🇩🇪Germany marc.bau

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @marc.bau
  • Status changed to Postponed: needs info 1 day ago
  • 🇭🇺Hungary nagy.balint

    Hi!

    I unfortunately cannot reproduce it on Chrome in a fresh Drupal 11 install with Olivero
    (I guess there should not be a big difference between 11 and 10.3.2 regarding this issue)

    And on mobile currently chosen will not apply 🐛 Chosen is not working on mobile devices? Closed: duplicate

  • 🇩🇪Germany marc.bau

    In the other case is a note - mobile work in 4.x?

    I try to create the repro plan soon with screenshots. But I cannot test on D11 as there is no xampp with PHP 8.3 available.

  • 🇭🇺Hungary nagy.balint

    As far as I checked today https://github.com/JJJ/chosen (which is used in 4.x) also displays only a normal select on mobile.

    The original reasons behind it can be found here https://github.com/harvesthq/chosen/pull/1388

    I wonder if we can override the AbstractChosen.browser_is_supported = function() (which is defined in chosen.jquery.js)
    somewhere around line 24 of the chosen.js in our module.
    Because in that case we could make it configurable to show it or not for Android and iOS.

  • 🇩🇪Germany marc.bau

    Well, all I have tested was decreasing my screen size by downsize my browser window. The site is currently only on my computer what makes real mobile tests a bit difficult. :-)

  • 🇩🇪Germany marc.bau

    huh... I played with it and found some problems.

    1. Make the browser window as narrow as possible and the field overflows
    2. Reload the narrow windows and the field gets resized to the available view port and does not overflow
    3. Make the window wider... and now the title and form and descripton become all inline (huh?)

    I have no idea how this works, but i tend to say there are breakpoint issues or a javascript event is not firing that resizes the form field.

    Some screenshots:



  • 🇭🇺Hungary nagy.balint

    I think at this point often websites implement their own design for these chosen elements.

    We can always improve the default css of chosen, but need to be careful with it.

    Of course the first issue here is to see if we can enable chosen on mobile screens, as without, mobile phones will anyways only see a standard HTML select.

Production build 0.71.5 2024