Problem/Motivation

The modal dialog box stretches to the full width of the screen and does not depend on the size of the window content. It is necessary to limit the width of the dialog box when the screen resolution is more than 768px, as it was previously.

Steps to reproduce

  1. Install Paragraphs, create a paragraph type, and attach it to a content type.
  2. Go into "Manage form display" for the content type
  3. Next to the paragraph field that you created, set the widget dropdown value to "Paragraphs EXPERIMENTAL"
  4. Within the options for this widget (click the cog button), change the "Add mode" to "Modal form"
  5. Add some content and add the paragraph. The modal will appear and it'll be wide.

Modal dialog

Comments

kvantstudio created an issue. See original summary.

kvantstudio’s picture

StatusFileSize
new1.32 KB
kvantstudio’s picture

Status: Active » Needs review
larowlan’s picture

kvantstudio’s picture

Patch https://www.drupal.org/files/issues/2021-01-07/3191497.patch does not solve the problem. I have solved it myself by modifying CSS styles in my patch.

bnjmnm’s picture

#3191497: core/jquery.ui.dialog is missing core/jquery assets would not impact this. Were the problem surfacing here, the dialog wouldn't even open. It would only occur on pages where core/jquery.ui.dialog is literally the only jquery-using library loaded on that page.

I notice max-content is used in the #2 patch. Drupal will be supporting IE11 until 10 at the earliest, and max-content is not supported in IE11. Having to still consider IE11 is unpleasant to most of us. Fortunately, there are efforts being made to officially set an IE11 expiration date.
There may be some variables in variables.pcss.css that can be used for the max-width value. Using an existing variable defined there provides assurance that it's consistent with Claro design and may land quicker.

bnjmnm’s picture

Title: The modal dialog box stretches to the full width » Paragraphs experimental widget "add paragraphs" dialog box stretches to the full width
Status: Needs review » Needs work
Issue tags: +Needs issue summary update

This is not a problem with all modals in Claro, so ideally the solution would be more specific to the use case that is causing the problem. I identified why this is happening in the add paragraph widget:

var dialog = Drupal.dialog($element, {
      autoResize: false, // Without this setting the width is fine 
      resizable: false,
      title: title,
      width: 'auto',
      paragraphsModalDelta: $modalDelta,
    });

With this in mind, the next steps should probably be:

  • Identify what about dialog is different when autoResize: false, is set
  • Identify why Claro doesn't cooperate well with the differences identified in the previous step
  • Create a patch that targets the autoResize: false use case as much as possible. The less general the fix, the less concerns there will be of side effects, and that will help this get committed sooner.

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

Drupal 9.1.10 (June 4, 2021) and Drupal 9.2.10 (November 24, 2021) were the last bugfix releases of those minor version series. Drupal 9 bug reports should be targeted for the 9.3.x-dev branch from now on, and new development or disruptive changes should 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.

mherchel’s picture

Issue summary: View changes

Updating summary

mherchel’s picture

I tracked this down to Claro disabling some jqueryui dialog CSS at https://git.drupalcode.org/project/drupal/-/blob/9.4.x/core/themes/claro...

  core/drupal.dialog:
    css:
      component:
        assets/vendor/jquery.ui/themes/base/dialog.css: false

If you comment out this code, the modal will look correct. I'm going to try to figure out why this was added and see if we can bring in the additional needed styles.

mherchel’s picture

Version: 9.3.x-dev » 9.4.x-dev
Status: Needs work » Needs review
Issue tags: -Needs issue summary update
StatusFileSize
new807 bytes
new828 bytes

Proper fix attached!

The issue was that the .ui-dialog element needed to be set to position: absolute;. See this code within jQueryUI: https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/assets/vend...

This jQueryUI CSS file is removed in claro.info.yml, so we need to add this CSS into Claro.

These patches move over the relevant CSS. Patches attached for both 9.4.x and 10.0.x

bnjmnm’s picture

Status: Needs review » Needs work

Excellent detective work! Could this fix be added to core/themes/claro/css/components/dialog.pcss.css instead of the broader theme.pcss.css? That is where the style originally was until it was removed by me 😳 in #3023311: Modal dialog style update to address an issue with the close icon not centering properly in Chrome.
Fortunately, the close-button-centering in Chrome does not appear to be a problem anymore. I manually tried to reproduce the problem - different dialog configs and Zoom levels, but it seems to be addressed in the browser and we can bring back what is apparently an important bit of positioning.

idebr’s picture

Status: Needs work » Needs review
StatusFileSize
new836 bytes

Attached patch moves the additional css from components/jquery.ui/theme.pcss.css to components/dialog.pcss.css

bnjmnm’s picture

Status: Needs review » Reviewed & tested by the community

Looks like a good fix. It brings back some default jQuery UI positioning CSS that probably shouldn't have been removed (by me) to begin with.

I imagine the change that led to this issue may have been noticed had it happened in an issue with smaller scope, but #3023311: Modal dialog style update was huge, and the change did fix an at-the-time Chrome issue.

mherchel’s picture

StatusFileSize
new826 bytes

Attached is the patch from #14 for 10.0.x

lauriii credited hmendes.

lauriii’s picture

Adding credits from #3186463: Dialog resize issue which I marked as duplicate.

lauriii’s picture

Title: Paragraphs experimental widget "add paragraphs" dialog box stretches to the full width » Dialog width and positioning issues in Claro

  • lauriii committed 78b86c1 on 10.0.x
    Issue #3191527 by mherchel, kvantstudio, idebr, bnjmnm, Abhijith S,...

  • lauriii committed 703f46d on 9.4.x
    Issue #3191527 by mherchel, kvantstudio, idebr, bnjmnm, Abhijith S,...

  • lauriii committed 75d35ca on 9.3.x
    Issue #3191527 by mherchel, kvantstudio, idebr, bnjmnm, Abhijith S,...
lauriii’s picture

Version: 9.4.x-dev » 9.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 78b86c1 and pushed to 10.0.x. Also committed 9.x patch to 9.4.x and cherry-picked to 9.3.x because Claro is experimental and this is fixing a major bug. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.