Problem/Motivation

The Quickedit module has JavaScript which applies inline styles to the currently edited element.
This makes overriding the padding and positioning difficult.

In: FieldDecorationView.js the _pad and _unpad functions add positioning padding and margin and a fixed width which cannot be configured or easily disabled.

Steps to reproduce

On any page with Quickedit active, click an editable area, such as a block of text to edit. The div will now have inline styles added in addition to several classes.

Proposed resolution

1. Remove the javascript related to _pad and _unpad
This seems to predate the css border-box property since it includes code for setting padding independent of the width.

2. Replace the padding by toggling a css class so that it can be overridden by a theme or a class added by a loaded editor.
The padding should still be optional by the object returned from the getQuickEditUISettings function.

Remaining tasks

  1. Get agreement this code can be safely removed
  2. Remove the existing code and replace with a class toggle
  3. Add css for the new class to quickedit.theme.css.

Issue fork drupal-3196689

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

zrpnr created an issue. See original summary.

zrpnr’s picture

Status: Active » Needs review
wim leers’s picture

I am 90% certain that this was done to be as portable/robust as possible — not every theme has a predictable set of selector specificity, and hence generic CSS could easily break, especially for common CSS properties such as padding. Note that the inline CSS is also carefully reverted.

AFAICT the proposed changes still suffer from that weakness?

wim leers’s picture

Title: Remove legacy Quickedit js style changes » Remove legacy Quick Edit JS style changes
Status: Needs review » Postponed (maintainer needs more info)
zrpnr’s picture

not every theme has a predictable set of selector specificity, and hence generic CSS could easily break

But in this case, isn't it desirable for a theme to be able to override the quickedit styles?
The inline style is the highest specificity (except for !important) and means the px values on padding are too robust.

Also, the js appears to have been written before CSS3 box-sizing property was in wider use, since the comments refer to how "padding changes affect width". The js sets a fixed width on the element as well as adding a top and left offset.

I had a tough time step-debugging where this happens- but the top and left values seem to be removed when CKEditor instantiates. In other editors it would cause a visible "jump" as the editable area position is offset. When the editable area is blurred that calculated offset remains and can compound.

Since the purpose of this js is apparently just to add padding, I'm confused as to why this wouldn't be better handled in css where it is more understandable, flexible and overridable.

wim leers’s picture

But in this case, isn't it desirable for a theme to be able to override the quickedit styles?

Fair point!

Back then, the rationale was that not every theme should need to bear the burden of Quick Edit-specific CSS just to support Quick Edit. This is how Quick Edit was able to avoid all the theme-specific CSS pains that Settings Tray has been seeing.

Also, the js appears to have been written before CSS3 box-sizing property was in wider use, since the comments refer to how "padding changes affect width".

This I am less certain about, but I vaguely recall this being about Quick Edit working with all themes, regardless of what box-sizing the affected elements use in the currently active theme.

Does that make sense? I could be completely wrong here :)

Since the purpose of this js is apparently just to add padding, I'm confused as to why this wouldn't be better handled in css where it is more understandable, flexible and overridable.

For the reason cited at the beginning of this comment 🤓

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.

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.

spokje’s picture

Project: Drupal core » Quick Edit
Version: 9.4.x-dev » 1.0.x-dev
Component: quickedit.module » Code

Due to Quickedit being moved out of Drupal Core and into a Contrib Module, moving this issue to the Contrib Module queue.