Problem/Motivation
Currently, tabledrag displays a warning message when a row is dragged, stating that changes are not saved until the form is submitted.
However, There are other tabledrag changes that warrant this warning message (e.g 'Manage display' screen, when the settings of a formatter are changed), changing a widget, etc.
Additionally, layout builder added some code that results in formatter changes incorrectly being saved as soon as the change is made, instead of requiring a save on the manage display/manage form display form . That should be addressed here so the need to save these settings in the tabledrag is consistient.
Steps to reproduce
Make any change that requires saving manage display/manage form OTHER than moving a row, and notice that there is no warning that the manage display/manage form display form must be submitted to save the changes, despite that being necessary to save the changes.
Proposed resolution
With JS, trigger the "must be saved" warning to appear based on any change that will not be stored until the manage display/manage form display form is submitted.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#65 | Screen Recording 2023-03-15 at 8.29.39.gif | 372.83 KB | lauriii |
Issue fork drupal-857312
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:
- 857312-add-a-changes changes, plain diff MR !3562
Comments
Comment #1
andypostSuppose we need js.behavior tableDragSetCaption/Message
Comment #2
yched CreditAttribution: yched commented- Marked #940450: Change notification message fails when changing 'hidden' status as dupe
- Less cryptic title, so that it can be more easily found
Still on my todo, but not in the top 3 positions for now :-(.
Comment #3
adrinux CreditAttribution: adrinux commentedA definite UX issue. Took me ages to figure out I needed to save my changes to the display format on 'manage display'.
Comment #4
swentel CreditAttribution: swentel commentedSubscribe: we have the same issue on manage fields screen with field_group, but I guess the patch will fix it on a broader level ?
Comment #5
mlncn CreditAttribution: mlncn commented#1025976: Updating a field formatter at Manage display fields does not save the change, and the user is not warned of this marked duplicate, bumping and tagging.
Comment #6
Stalski CreditAttribution: Stalski commentedWas there already a starting patch for this somewhere?
Comment #7
yched CreditAttribution: yched commented@Stalski : no, not really :-(.
I'm planning to get back at this in the next couple days, FWIW.
Comment #8
robertgarrigos CreditAttribution: robertgarrigos commentedsubscribing
Comment #9
yched CreditAttribution: yched commentedHere's a first version.
Still has a couple refactoring todos, but should mostly work.
- Adds a "changes won't get saved until the form is submitted" message when submitting the "formatter settings" subform.
- Makes sure this message won't be duplicated with tabledrag's own warning message
- Makes sure "changed row" markers (the orange asterisk next to the row name) are preserved through ajax / non-js-multistep refreshes.
+ bumping to 'major'. The current lack of a warning message that formatter settings are not immediately saved can be really confusing the first times you hit this.
Comment #10
yched CreditAttribution: yched commentedeasier tracking
Comment #11
yched CreditAttribution: yched commentedOops, something went wrong with the field_ui.js hunk. Reroll.
Comment #12
Stalski CreditAttribution: Stalski commentedPatch works on display (field_group and fields). As field_group did some altering to allow the configuration of field_groups in the fields screen, this is not implemented in the patch. So this does not work yet.
I am not sure about the approach either. This patch works on a fix rather than a improvement of core imho.
Comment #13
yoroy CreditAttribution: yoroy commentedSubscribe & tagging. For Drupal 8 we of course save everything automagically and let people undo as they like it :)
But yes, please do add this warning. (Doesn't views disable the submit button untill you update settings? Can we borrow? Just thinking out loud…)
Comment #14
yched CreditAttribution: yched commentedStill a couple issues to clean in the 'References' queue, then I'm getting back at this.
@yoroy : I'm not sure disabling the global 'Save' button would be useful here. Actually, in current D7, the formatter settings are correctly saved if you bypass the 'Submit' button for the subform and hit 'Save' directly.
Saving automagically in D8 : dunno, why not if it becomes a UX pattern across all of core. Then again, I'm not sure we really want this. If I'm configuring the display for the various fields as a whole, I don't want the micro changes to go live directly as I progressively make them.
Same as for views: edit the view as a whole, save once when you're globally done. Intermediate steps are not relevant per se.
Comment #15
catchLeaving as 'major', but moving to a task, this is more of an enhancement than a straight bug.
Comment #16
jasongrimes CreditAttribution: jasongrimes commented+1, this UX issue confused me for quite awhile.
Comment #17
donSchoe CreditAttribution: donSchoe commented+1
Comment #18
Fidelix CreditAttribution: Fidelix commentedIn my opinion, the settings shouldn't be saved automagically if it'll introduce problems. This could be a feature for D8, though, as when you click the "update" button of the specific field settings, you really expect the setting to be permanently saved.
Is there a chance that this will get into the December 5 (7.10) release?
Comment #19
klonos...coming from the now closed as duplicate #1428532: After editing a widget's properties, there should be a hint that informs that form needs to be saved too (a-la Views)
#11 -manually applied- fixes the problem partially (using latest devs of core and field_group). Tested the "Manage fields" tab & the "Manage display" tab (default only - not the teaser, but I guess it works the same for that too).
"Manage display" tab
Behaves (mostly) as expected with the patch applied when a widget's settings are updated (tested changing the label of a vtab within a vtab group):
[v] no confusing "Your settings have been saved" message on widget settings update.
[x] no dirty flag set in the widget row that has been updated to indicate that though.
[v] "* Changes made in this table will not be saved until the form is submitted." message to indicate that the form needs to be saved too in order for the settings to be finally saved.
[v] "Your settings have been saved" message only after submitting the whole form ("Save" button).
Minor WTF that happens only on successive updates of widgets: Changing the widget and hitting the "Update" button does bring the "* Changes made in this table will not be saved until the form is submitted." message, but any "Your settings have been saved" message from a successful previous save doesn't go away till the page gets refreshed. So you end up having both messages in this case. So, we need to make sure that we remove any previous messages when we display the "* Changes made in this table will not be saved until the form is submitted." message.
"Manage fields" tab
Doesn't behave as expected at all:
[v] no confusing "Your settings have been saved" message on widget settings update.
[x] still, no dirty flag set in the widget row that has been updated to indicate that.
[x] still, no warning message or indication whatsoever that the form needs to be saved too.
[v] "Your settings have been saved" message only after submitting the whole form as expected.
Comment #20
donquixote CreditAttribution: donquixote commentedThe annoying thing now is that the message disappears on ajax response.
See #1664836: Fields tabledrag form jumping up and down due to message.
What we need is:
- Show the message as soon as someone changes a form value (esp, if someone rearranges the rows). Esp, let it survive ajax response.
- Do not hide the message until the form is submitted (that is, don't hide it at all)
- Never show more than one message.
- Optionally, hide the message if the form returns to its original state (probably we cannot reliably detect this, so forget about it)
Now, we probably all know this already, and this comment does not help at all. Ok...
Comment #21
nick_schuch CreditAttribution: nick_schuch commentedMarked a previous commit as a duplicate and moving to this thread.
http://drupal.org/node/1536252
This is my patch.
Comment #22
klonosShould I test this against D8 or D7? ...asking because as you can see from #19 my issue was with Field group before this shifted to a core issue.
Comment #23
tim.plunkett#1770720: [META] Gradual changes to Field UI says that this should use #1642062: Add TempStore for persistent, limited-term storage of non-cache data
Which would be pretty cool!
Comment #24
swentel CreditAttribution: swentel commentedNew patch against 8.x after all the changes. 2 things still todo
- also act on label change
- figure out the position of the message - with tabledrag it's after 'Show row weights', after an ajax request, it's before, ugh
Also - only test this against core, we'll see for D7 backport if we need to help out fieldgroup/ds or not a little further or not.
@tim yes, we really hope to use tempstore, but fore now see if we can get this one in for backport to D7 :)
Comment #25
swentel CreditAttribution: swentel commentedMoving back to task, implementing this as temp store is going to be insane hard. Patch goes a little further that it also triggers it on a label change, but still needs work, however, moving to features now first :)
Comment #26
swentel CreditAttribution: swentel commentedBringing this on the radar
Comment #27
swentel CreditAttribution: swentel commentedRemoving focus, added on #1963340: Change field UI so that adding a field is a separate task too
Comment #28
swentel CreditAttribution: swentel commentedComment #29
klonosThis issue is listed in #1770720: [META] Gradual changes to Field UI and #1642062: Add TempStore for persistent, limited-term storage of non-cache data (that is now in) is supposed to "kill" this issue here.
Comment #30
amateescu CreditAttribution: amateescu commentedJust closed a duplicate: #2172325: Manage display screen should warn you to save
Comment #31
yoroy CreditAttribution: yoroy at Wunder commentedSo, with #1642062: Add TempStore for persistent, limited-term storage of non-cache data fixed, are we done here?
Comment #32
yoroy CreditAttribution: yoroy at Wunder commentedComment #33
mgiffordThe patch in #25 no longer applies (not too surprising).
Comment #34
deepakaryan1988Comment #35
deepakaryan1988The whole directory structure has been changed. I need some help getting #25 to re-roll. :(
Comment #36
webchickIt sounds from recent comments like step #0 might be verifying the problem still exists.
Comment #40
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer and at Appnovation commentedRemoving the tag because Drupal is very different now, we should probably approach this with fresh new eyes :)
Comment #41
andypostBug still exists
1. visit admin/structure/types/manage/article/display
2.1 drag rows - no message
2.2 change formatter settings - no message
Comment #42
andypostActually when used at admin/config/people/accounts/display page
I can see the message only when something is moved in visible section
But if move something in Hidden - state is cleared and table flickering
Comment #52
tim.plunkettComment #53
tim.plunkettComment #56
bnjmnmComment #57
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis appears to need an issue summary update.
This was a spinoff task so what is being addressed here?
What is the proposed solution?
Remaining tasks?
Etc.
Thanks.
Comment #58
bnjmnmRunning into some inconsistency between the tests an local that I haven't fully figured out yet. In some cases changing formatter settings and clicking the "update" button saves those changes, in other cases it doesn't.
Scenario: Article content type, update the Trimmed limit of the Body field with the summary or trimmed formatter in the default view mode
Formatter setting changes save after clicking Update, no need to save the manage display form as well
Formatter setting changes do not save after clicking Update. The manage display form must be saved for the changes to stick
Since this worked in Umami and not in Standard, I tried starting with a Standard profile install and enabling modules one by one until it matched Umami, and Standard continued to not save the settings while Umami did.
Because a Body field in a new content type in Umami doesn't save the settings, while Article does, I compared the field config and there's no differences aside from the names.
There's probably other config in Umami that could be impacting this. Trying to narrow down what that could be.
Comment #59
bnjmnmTalked to @effulgentsia about this and it sounds like the not-Umami (the majority of the scenarios) is the expected behavior, so that is a step towards understanding this. It would be good to understand why, though, as there may be a broader need to distinguish saving-changes from non-saving ones so the warning only appears for the latter.
Comment #60
lauriiiThe inconsistency between Standard and Umami install profiles is created by Layout Builder module. Specifically, Layout Builder overrides enabled in Umami is causing this.
This is because we have some code in
\Drupal\field_ui\Form\EntityDisplayFormBase::buildFieldRow
to ensure that any fields that have no applicable widgets, are disabled. Something about this logic leads into the entity display being re-saved every time the page is loaded, when Layout Builder overrides are enabled. 🤯Comment #61
tim.plunkettNo functional test coverage was written when the following check was introduced in #2552799: FieldType with no available widget causes Fatal error, so we'll need to write some:
I believe the fix is a straightforward one, but I'm going to work on tests first.
Comment #62
tim.plunkettCode is NR, still needs IS update
Comment #63
tim.plunkettI think I pushed too quickly, hopefully this patch will fail correctly
Comment #65
lauriiiTested this manually and it seems to work pretty well. Something that is a bit off is that every time something is changed on the form, the message above the table flashes. I'm wondering if that's something we would be able to address?
Comment #66
bnjmnmFixed #65 with this commit.
Comment #67
smustgrave CreditAttribution: smustgrave at Mobomo commentedApplied MR 3562
Went to the form display.
Changed a formatter option and confirmed the warning.
Changed a formatter setting and saved. Confirmed the warning.
Not noticing the flicker mentioned in #65.
Looks good
Comment #69
nod_There are issues when dragging rows from the active region to the disabled region in the field UI.
To reproduce:
I was able to remove all the rows from the active region by dragging things around a bit switching rows from active to disabled region. so definitely a timing issue somewhere.
The warning is added when reordering rows but it gets hidden is a row is moved from active to disabled, even though nothing is saved, the warning should be kept.
Additionally the use of the ajaxStart/Success event is a bit problematic since we have our own command processing on top of the jQuery ajax calls this adds a dependency on a workaround in core, which isn't ideal. That might be one of the thing that makes the UI unreliable (haven't looked closely). See #3324062: [Regression] Changes to Drupal.ajax in 9.5.x have caused regressions in paragraphs_features module.
Comment #70
nod_Umm now the row disapearing/moving to the disabled region doesn't happen. would be good for someone else to try and move things around and see if some unexpected rows gets moved to the disabled region.
The changed warning removed when dragging from active to disabled region is still an issue though (because things are not actually saved).
Comment #71
nod_Nice, this solves the issues when dragging rows.
There a minor inconsistency from the removed
->save()
, the changed marker (*) gets removed from all rows when dragging a row across the active/disabled region, ideally it shouldn't be removed but the main warning is still displayed. Information that a save is needed is still there it's just not clear what changed anymore.couple of details in the MR comments
Comment #72
bnjmnmGood feedback from @nod_
Comment #73
smustgrave CreditAttribution: smustgrave at Mobomo commentedOpen threads still it seems.
Comment #74
bnjmnmComment #75
smustgrave CreditAttribution: smustgrave at Mobomo commentedSeems to have build errors
Running PHPStan on *all* files.
------ ------------------------------------------------------------------------
Line core/modules/field_ui/src/Form/EntityDisplayFormBase.php
------ ------------------------------------------------------------------------
708 Ignored error pattern #^Variable \$updated_rows might not be
defined\.$# in path
/var/www/html/core/modules/field_ui/src/Form/EntityDisplayFormBase.php
is expected to occur 1 time, but occurred 2 times.
720 Variable $updated_rows might not be defined.
------ -------------------------------------------------------
Comment #76
bnjmnmComment #77
bnjmnmWill need to look into the test failures.
Comment #78
bnjmnmComment #79
smustgrave CreditAttribution: smustgrave at Mobomo commentedLike the commit message "do not double dip change handlers"
Retested following
Went to the form display.
Changed a formatter option and confirmed the warning.
Changed a formatter setting and saved. Confirmed the warning.
Comment #80
lauriiiPosted review on the MR
Comment #81
bnjmnmComment #82
hooroomooConfirmed that all feedback was addressed and saw that all worked as expected when testing manually
Comment #83
lauriiiCommitted 1996c9d and pushed to 10.1.x. Thanks!
We should write a CR for the new ajax command. Moving to NW for that.
Comment #85
bnjmnmChange record added.
Comment #88
BerdirI'm seeing a possibly unexpected side effect from this in our behat tests, it looks like it's no longer possible to change the region select and edit settings at the same time:
The settings_edit click no longer works, I need to save first. Not an issue when moving it up with drag and drop, but I can reproduce manually when I switch to displaying row weights.
It could be another issue, but this seems very related.
Comment #89
herved CreditAttribution: herved commentedAnother side effect: if we have a custom field settings form element with an ajax callback, and we click any input after that callback run, the entire form refreshes and we loose our input values.
This breaks for example Display Suite (but not exclusively, I also encountered the same in one of our projects in custom code):
- Go to manage display
- for any field, edit settings and change "Field Template" from "Master" to "Minimal"
- click for example the "Show label colon" or any other field
-> the entire form refreshes and we loose all values we entered.
Specifically, the changes in
Drupal.fieldUIDisplayOverview.field
seems to cause that.Either
ds_field_ui_display_overview_multistep_js()
needs to be updated to add theajax-new-content
class (similar to howEntityDisplayFormBase::multistepAjax
does) or is this be considered as a core bug/regression?Edit: DS issue created #3402902: Field formatter settings form and AJAX issue (regression on 10.1.x after #857312)