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
Comment | File | Size | Author |
---|---|---|---|
#52 | views_quick_edit-2700147-52.patch | 5.99 KB | vakulrai |
#51 | interdiff-2700147-49-51.txt | 2.88 KB | vakulrai |
#51 | views_quick_edit-2700147-51.patch | 5.99 KB | vakulrai |
#49 | 2700147-49.patch | 5.83 KB | ayushmishra206 |
#36 | 2700147-quickedit-36.patch | 5.82 KB | dermario |
Comments
Comment #2
garethhallnz CreditAttribution: garethhallnz commentedAttached patch
Comment #3
garethhallnz CreditAttribution: garethhallnz commentedAttached patch
Comment #4
Wim LeersWe don't want to hardcode this sort of thing.
IIRC, the actual bug here is either:
I know I've been on an issue related to this before.
Pinged @tim.plunkett about this.
Comment #5
Wim LeersComment #6
Wim LeersAlso pinged @yched: https://twitter.com/wimleers/status/724635440859516928
Comment #7
garethhallnz CreditAttribution: garethhallnz commentedHey Wim,
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
Perhaps we should follow the same convention and change
to
Comment #8
tstoecklerIt 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
orfull
) in case an incorrect view mode is passed, and then returns an empty string as though everything is fine leading to a vanished field.Comment #9
dawehnerYeah conceptually this sounds like a 404 for me. The URL requested a certain view mode, but we could not find it.
Comment #10
garethhallnz CreditAttribution: garethhallnz commentedSurly it's reasonable to have some level of fallback?
So why would it be bad to define a default view_mode as per #7?
Comment #11
Wim LeersBecause we're guessing. And assuming
'default'
exists for all entity types.This should be fixed in Views.
Comment #13
Wim LeersComment #14
Wim LeersComment #17
samuel.mortensonHere's a port of the patch from #2952300: Drag-and-drop image uploading in Quick Edit doesn't work on Media fields, only File fields, with test coverage. This is ready for review now.
Comment #19
samuel.mortensonComment #20
LendudeSince 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.
Comment #21
tstoecklerSo 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.
Comment #22
BerdirYeah, 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?
Comment #23
Wim LeersShould we make the consistently wrong thing the new right thing then?
Comment #25
rang501 CreditAttribution: rang501 at ADM Interactive commentedHi!
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.
Comment #26
Andrew Gorokhovets CreditAttribution: Andrew Gorokhovets as a volunteer commentedJust confirm that #25 works for me
Comment #27
saschaeggiPatch #25 works for me as well.
Comment #28
webchickGreat to see a fix, but we do need a test.
Comment #29
malte.koelle CreditAttribution: malte.koelle at Unic commentedI 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
Comment #30
dermarioI 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.
Comment #33
dermarioOk the tests in #30 are failing. For some reason
getViewModeOptions
was renamed togetViewModesOptions
in #29 and i didn't see that. Sorry for that. Here are 2 new patches that hopefully work like they should.Comment #36
dermarioFixing patch names and the file ending of the interdiff - to give a better overview.
Comment #38
ckngPatch #36 is working for us in resolving the issue #3061101: Quick Edit with Paragraphs: stuck on 'saving'.
Comment #44
pameeela CreditAttribution: pameeela commentedClosed #2982359: Quick Edit hides field on save as a duplicate so added it here as related add added the contributors here for credit.
Comment #45
pameeela CreditAttribution: pameeela commentedComment #47
quietone CreditAttribution: quietone as a volunteer commentedThere 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.
File name should be QuickEditDefaultViewModeTest.php
"Tests Quick Edit works when the default view mode does not exist." would be simpler and correct the case of Quick Edit.
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?
Comment #48
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedComment #49
ayushmishra206 CreditAttribution: ayushmishra206 at OpenSense Labs commentedRerolled patch #36 for 9.2.x and made the suggested changes in #47 along with some coding standards fixes.
Comment #51
vakulrai CreditAttribution: vakulrai as a volunteer and at QED42 for QED42 commentedUpdated tests for deprecated assert statements , missing test standards and missing code checks in tests.
Comment #52
vakulrai CreditAttribution: vakulrai as a volunteer and at QED42 for QED42 commentedUpdated Coding standards.
Comment #53
John Pitcairn CreditAttribution: John Pitcairn commentedThe patch at #52 still works for 9.1.x. I'd say RTBC, pending confirmation it works on 9.2.x.
Comment #56
SpokjeDue to Quickedit being moved out of Drupal Core and into a Contrib Module, moving this issue to the Contrib Module queue.
Comment #57
gonssalI 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.
Comment #58
sivaranjaniram CreditAttribution: sivaranjaniram commentedThis bug still exists Drupal 9.4.7 version. This patch #52 applied but bug still exist.