Problem/Motivation

When using a view that shows content and the content is rendered using the 'default' view-mode; when you click save it returns nothing.

1. Create a view (see config below)
a) Create block: true
b) Display format: Unformatted list of teasers
c) save and edit
d) Click on teaser in "Show:Content | Teaser"
e) Change View mode from teaser to default
f) Save

2. Add the view block to a theme region

3. Create a basic page

4. Use quick edit feature to edit on a node served form the view.

5. When you click save to whole field will disappear.

When I inspect the ajax response made to example.com/quickedit/form/node/NID/body/en/default?_wrapper_format=drupal_ajax I can see no data has been retuned

Response:
[{"command":"quickeditFieldFormSaved","data":"","other_view_modes":[]}]

I have attached a video demonstrating the issue.

Proposed resolution

I think the parameter $view_mode_id in QuickEditController->renderField should know how the handle the 'default' view-mode

CommentFileSizeAuthor
#52 views_quick_edit-2700147-52.patch5.99 KBvakulrai
#51 interdiff-2700147-49-51.txt2.88 KBvakulrai
#51 views_quick_edit-2700147-51.patch5.99 KBvakulrai
#49 2700147-49.patch5.83 KBayushmishra206
#36 2700147-quickedit-36.patch5.82 KBdermario
#36 2700147-quickedit-36-test-only-should-fail.patch3.98 KBdermario
#36 2700147-interdiff-36.txt1.85 KBdermario
#33 2700147-quickedit-31.patch5.82 KBdermario
#33 2700147-quickedit-31-test-only-should-fail.patch3.98 KBdermario
#33 2700147-interdiff-31.patch1.85 KBdermario
#30 2700147-quickedit-30-test-only-should-fail.patch3.98 KBdermario
#30 2700147-quickedit-30.patch5.82 KBdermario
#29 view-uses-non-existent-default-view-mode-#29.patch4.18 KBmalte.koelle
#29 view-uses-non-existent-default-view-mode-#29-interdiff.txt2.34 KBmalte.koelle
#25 2700147-25.patch1.83 KBrang501
#17 2700147-17-test-only.patch1.87 KBsamuel.mortenson
#17 2700147-17.patch3.67 KBsamuel.mortenson
#2 quickedit-default_view_mode_support-2700147-2-8.0.5.patch874 bytesgarethhallnz
quickedit-issue.mp422.67 MBgarethhallnz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

garethhallnz created an issue. See original summary.

garethhallnz’s picture

garethhallnz’s picture

Status: Active » Needs review

Attached patch

Wim Leers’s picture

We don't want to hardcode this sort of thing.

IIRC, the actual bug here is either:

  1. Views allowing you to select the Default view mode, which is not an actual view mode
  2. or Entity API having changed some metadata that causes Views to expose "default" as a view mode, which wasn't the case before

I know I've been on an issue related to this before.

Pinged @tim.plunkett about this.

Wim Leers’s picture

Title: Quick edit does not work with default view-mode in a view » Quick Edit does not work with "default" view mode
Wim Leers’s picture

garethhallnz’s picture

Hey Wim,

We don't want to hardcode this sort of thing.

When I looking at the issue I had this concern too; then again node_view() sets the default view_mode in the function arguments with

node_view(NodeInterface $node, $view_mode = 'full', $langcode = NULL)

Perhaps we should follow the same convention and change

protected function renderField(EntityInterface $entity, $field_name, $langcode, $view_mode_id) {

to

protected function renderField(EntityInterface $entity, $field_name, $langcode, $view_mode_id = 'full') {
tstoeckler’s picture

It is problematic that Views allows you to use Default as an explicit view mode. However, AFAIK that itself is just a workaround for a deeper issue that you can also face in Quickedit: You can have entity types without any view modes. As view modes are only stored in Config and there is no way to provide them with code, you can get into a state where you have no view modes.

I still find QuickEditController::renderField() buggy, though. It invokes a hook on a non-existing module (i.e. default or full) in case an incorrect view mode is passed, and then returns an empty string as though everything is fine leading to a vanished field.

dawehner’s picture

Yeah conceptually this sounds like a 404 for me. The URL requested a certain view mode, but we could not find it.

garethhallnz’s picture

Surly it's reasonable to have some level of fallback?

So why would it be bad to define a default view_mode as per #7?

Wim Leers’s picture

Title: Quick Edit does not work with "default" view mode » Views uses non-existent "default" view mode, which causes Quick Edit to break
Version: 8.0.5 » 8.2.x-dev
Component: quickedit.module » views.module
Issue tags: +Needs tests, +VDC

So why would it be bad to define a default view_mode as per #7?

Because we're guessing. And assuming 'default' exists for all entity types.

This should be fixed in Views.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Wim Leers’s picture

Issue tags: +Entity Field API
Wim Leers’s picture

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

samuel.mortenson’s picture

Status: Needs review » Needs work

The last submitted patch, 17: 2700147-17-test-only.patch, failed testing. View results

samuel.mortenson’s picture

Status: Needs work » Needs review
Lendude’s picture

Component: views.module » quickedit.module

Since both the fix and test are in quickedit, moving this to that queue. If this turns into something Views specific feel free to move it back.

tstoeckler’s picture

So this makes it so that quickedit will actually render fields in the 'default' view mode, right? I don't think that is the correct fix. The 'default' view mode was never meant to be an actual view mode, it's just an implementation detail of the UI to facilitate quicker configuration. It has already crept into various places e.g. Views, etc. but I don't think it's wise to continue that pattern. We have #2844203: Improve/Simplify situation around Default/Full view modes/view displays to improve that situation in general, but I don't think it's a good idea to continue in this direction (i.e. to "worsen" the situation from my point of view).

It's quite possible that I'm missing something, maybe we can get @Berdir to comment here, I think he has a much broader picture of the whole situation.

Berdir’s picture

Yeah, I'm conflicted :)

I fully agree with @tstoeckler that default should never be used like that.

The problem is, it is. Even our API's, as this patch shows, return default as a view mode option. And I don't really see how we can get rid of that in 8.x (and I don't even see a way forward so far that is backwards-compatible in some way..).

Given that, it probably makes sense to do this, so that we're doing it consistently wrong ;)

And maybe re-open the other issue or create a new so that media by default does not use the default view mode for rendering?

Wim Leers’s picture

Given that, it probably makes sense to do this, so that we're doing it consistently wrong ;)

Should we make the consistently wrong thing the new right thing then?

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

rang501’s picture

Hi!
I have no idea, how and when it'll be fixed, but until then, here is a patch for 8.7.
Doesn't include tests.

Andrew Gorokhovets’s picture

Just confirm that #25 works for me

saschaeggi’s picture

Version: 8.6.x-dev » 8.8.x-dev
Status: Needs review » Reviewed & tested by the community

Patch #25 works for me as well.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Great to see a fix, but we do need a test.

malte.koelle’s picture

I started to create a test, but couldn't finish it. If someone has time they can finish it.
I’d appreciate any feedback on my current test.

Best Regards Malte

dermario’s picture

I created a test that basically bases on the approach in #17. Attached is also a test-only patch that's supposed to fail due to the missing fix from #25.

@malte.koelle i did go a different way with my test. Instead of rebuilding the steps in the video, i focused on the quickedit process, that uses the "default" view mode in its requests.

The last submitted patch, 30: 2700147-quickedit-30.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Status: Needs review » Needs work

The last submitted patch, 30: 2700147-quickedit-30-test-only-should-fail.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

dermario’s picture

Ok the tests in #30 are failing. For some reason getViewModeOptions was renamed to getViewModesOptions in #29 and i didn't see that. Sorry for that. Here are 2 new patches that hopefully work like they should.

The last submitted patch, 33: 2700147-quickedit-31-test-only-should-fail.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

The last submitted patch, 36: 2700147-quickedit-36-test-only-should-fail.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

ckng’s picture

Patch #36 is working for us in resolving the issue #3061101: Quick Edit with Paragraphs: stuck on 'saving'.

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

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now 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.

pameeela credited Deno.

pameeela credited jcandan.

pameeela credited rfsbsb.

pameeela’s picture

Closed #2982359: Quick Edit hides field on save as a duplicate so added it here as related add added the contributors here for credit.

pameeela’s picture

Issue tags: +Bug Smash Initiative

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

quietone’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

There is a test here but the file name isn't standard, removing the needs test tag. I will start a test against 9.2.x.

  1. +++ b/core/modules/quickedit/src/QuickEditController.php
    --- /dev/null
    +++ b/core/modules/quickedit/tests/src/Functional/QuickEditDefaultViewMode.php
    

    File name should be QuickEditDefaultViewModeTest.php

  2. +++ b/core/modules/quickedit/tests/src/Functional/QuickEditDefaultViewMode.php
    @@ -0,0 +1,113 @@
    + * Test quick edit does not break if view uses non-existent default view mode
    

    "Tests Quick Edit works when the default view mode does not exist." would be simpler and correct the case of Quick Edit.

  3. +++ b/core/modules/quickedit/tests/src/Functional/QuickEditDefaultViewMode.php
    @@ -0,0 +1,113 @@
    +   * Test views does not use a non-existent view mode, to avoid Quick Edit to break
    

    I am having trouble understanding this comment. Is this testing that Quick Edit works when the view does not have a view mode or that the view does not have a non existing view mode?

ayushmishra206’s picture

Assigned: Unassigned » ayushmishra206
ayushmishra206’s picture

Assigned: ayushmishra206 » Unassigned
Status: Needs work » Needs review
FileSize
5.83 KB

Rerolled patch #36 for 9.2.x and made the suggested changes in #47 along with some coding standards fixes.

Status: Needs review » Needs work

The last submitted patch, 49: 2700147-49.patch, failed testing. View results

vakulrai’s picture

Status: Needs work » Needs review
FileSize
5.99 KB
2.88 KB

Updated tests for deprecated assert statements , missing test standards and missing code checks in tests.

vakulrai’s picture

Updated Coding standards.

John Pitcairn’s picture

The patch at #52 still works for 9.1.x. I'd say RTBC, pending confirmation it works on 9.2.x.

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.

gonssal’s picture

I confirm the patch in #52 works with Drupal 9.3.

The problem not only affects Views, but basically any entity, because all of them have a Default view mode. For example Paragraphs or Media entities are also affected.

This can be seen by going to any entity's Manage display settings and seeing how all of them have a Default element at the start of the view modes tabs. So yeah I think there's no way to not support a Default view mode.

Although this issue has been moved to the not-in-core-anymore quickedit module, I think it would be nice if it was backported to 9.x, as it's still a bug.

sivaranjaniram’s picture

This bug still exists Drupal 9.4.7 version. This patch #52 applied but bug still exist.