Problem/Motivation

#2559877: [Regression] Quick editing a body field on Standard does not work has shown that quickedit relies quite a lot on the structure of the divs, which is problematic
as template could change quite a bit about them.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Comments

dawehner created an issue. See original summary.

davidhernandez’s picture

Issue tags: +JavaScript
mortendk’s picture

dunno if we should attach the issue that Quickedit now uses .region-content as a selector ? or seperate that into its own issue ?
we bashed around that back in #2407739: Remove classes from system templates r*.html.twig where the issue came up the first time.
i would suggest we used a data-attribute instead for this functionality & attached it to the body or main, else were opening up for so many doors where we can break this :/

swentel’s picture

Status: Active » Needs review
StatusFileSize
new1.24 KB

I think .quickedit-field should be fine. It's added by initializeField() in quickedit.js so even if there are no classes at all on a field, it should still work because the data-attribute is there (unless attributes aren't printed either, but that's shooting yourself in the foot then).

wim leers’s picture

Title: Ensure that quickedit relies less on the structure of the HTML » Ensure that Quick Edit relies less on the structure of the HTML
Status: Needs review » Reviewed & tested by the community
Related issues: +#2559877: [Regression] Quick editing a body field on Standard does not work, +#2178121: Document the requirements for themes for Quick Edit to work in/with them

I did some thorough manual testing. The solution in #4 makes a ton of sense. Many thanks!

This is super important for making it possible to have custom themes in Drupal 8 still support Quick Edit without subtle, non-explicit restrictions. It will ensure #2178121: Document the requirements for themes for Quick Edit to work in/with them will result in very simple instructions/guidelines for theme developers in D8.

nod_’s picture

Wouldn't we want at least a js- prefixed class name? or a data attribute?

wim leers’s picture

Status: Reviewed & tested by the community » Needs work

[…] js- prefixed class name […]

Right, I forgot that that is the new rule.

wim leers’s picture

Issue tags: +Novice, +js-novice

The last submitted patch, 4: 2559955-4.patch, failed testing.

wim leers’s picture

Status: Needs work » Reviewed & tested by the community

Testbot--

rainbowarray’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/editor/js/editor.formattedTextEditor.js
    @@ -63,7 +63,7 @@
           // Store the actual value of this field. We'll need this to restore the
           // original value when the user discards his modifications.
    

    Can we remove the gendering in this comment while we're at it. There has to be a better way to write this.

  2. +++ b/core/modules/editor/js/editor.formattedTextEditor.js
    @@ -63,7 +63,7 @@
    +      var $fieldItems = this.$el.find('.quickedit-field');
    
    +++ b/core/modules/quickedit/js/editors/plainTextEditor.js
    @@ -31,7 +31,7 @@
    +      var $fieldItems = this.$el.find('.quickedit-field');
    

    Wouldn't we want to change this to js-quickedit-field or a data attribute as nod_ suggested before we RTBC this?

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new1.54 KB
new1.55 KB

Oops, yes, I forgot about #7 in #10.

Wim--

yched’s picture

Status: Needs review » Reviewed & tested by the community

Nice ! RTBC then ?

rainbowarray’s picture

Status: Reviewed & tested by the community » Needs work

I manually tested this, and it seems to work. But don't we need to change the template output to use js-quickedit-field as well? I'm only seeing quickedit-field in the template markup.

wim leers’s picture

Status: Needs work » Needs review
StatusFileSize
new1.24 KB

#14: this is 100% JS-only. That's the whole point: to make Quick Edit not rely on the template markup. This patch makes Quick Edit's JS rely solely on the already-existing data-quickedit-* attributes, which cause this class to be added.

Except that this patch actually is relying on the non-existent .js-quickedit-field class; QuickEdit's JS still creates the quickedit-field class — see initializeField() in quickedit.js.

Renaming that class is actually out of scope here, because it would require changes to Quick Edit's JS, which would then have inconsistent class names.

So, re-uploading the patch in #4.

nod_’s picture

Status: Needs review » Reviewed & tested by the community

fair enough.

prestonso’s picture

Renaming that class is actually out of scope here, because it would require changes to Quick Edit's JS, which would then have inconsistent class names.

Notwithstanding the CSS selectors in quickedit.theme.css, which would break if quickedit-field is renamed js-quickedit-field in initializeField().

effulgentsia’s picture

Adding credit to @mdrummond for manually testing this.

  • effulgentsia committed 35fa967 on 8.0.x
    Issue #2559955 by Wim Leers, swentel, mdrummond: Ensure that Quick Edit...
effulgentsia’s picture

Status: Reviewed & tested by the community » Fixed

Pushed to 8.0.x.

Status: Fixed » Closed (fixed)

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