backdrop / backdrop-issues

Issue tracker for Backdrop core.
145 stars 40 forks source link

Move title of confirm form to a backdrop message #6733

Open robertgarrigos opened 1 month ago

robertgarrigos commented 1 month ago

Description of the need

I always found strange that the confirm form function sets the title of the page. This issue made me think about a practical solution to override this functionality. However, I would say it would be much better to change core.

Proposed solution

This is what happens now. The demonstration contrib module uses tabs:

Snapshots___My_Backdrop_Site_-_Vivaldi Snapshots___My_Backdrop_Site_-_Vivaldi

These two tabs show the title normally, but the third one is a confirm form:

Snapshots___My_Backdrop_Site_-_Vivaldi

and the title gets changed. Of course, you can still see the context in the breadcrumb, but what happens if you don't use the breadcrumb? Context indeed gets lost.

Wouldn't it be much nicer this?:

Snapshots___My_Backdrop_Site_-_Vivaldi

Alternatives that have been considered

I don't see an easy way to accomplish this functionality by altering code with a contrib module.

Additional information

I will provide a PR

Draft of feature description for Press Release (1 paragraph at most)

Confirm forms now show the title as a warning backdrop message.

robertgarrigos commented 1 month ago

This is how a blank backdrop works with this pr:

Your_first_post____Backdrop_-_Vivaldi

Instead of:

Are_you_sure_you_want_to_delete_Your_first_post_____Backdrop_-_Vivaldi

izmeez commented 1 month ago

This is fantastic. Looks good, much better. PR works and the code is a one line change. Now, what bad things can happen? I don't know.

izmeez commented 1 month ago

The PR also fixes the issue for the demo module, https://github.com/backdrop-contrib/demo/issues/32. It will change behaviour contrib modules are used to and may be a problem? Or may be an overall improvement?

izmeez commented 1 month ago

This issue may be really ancient and extends back to Drupal 7. If you go to a Drupal 7 site with something like the backup_migrate module, look at saved backups and go to delete one. The confirm question message shows in place of the title.

izmeez commented 1 month ago

Here is how this core fix improves the current backdrop-contrib/backup_migrate delete saved backup display. Before patch: bam-current-delete-confirm-screenshot

After patch: bam-core-patched-delete-confirm-screenshot

Both before and after show the wrong tab menu highlighted, so that's a separate issue for bam.

izmeez commented 1 month ago

Maybe, this can qualify as a bug fix?

indigoxela commented 1 month ago

I'm not really sure, whether this change isn't an A11Y regression.

Instead of providing the info in the page title AND the meta title for quick access, it's now just some text somewhere on the page. And the page title is the generic title of the content or item we're about to delete. No A11Y expert, though.

At the very minimum I'd expect the title to be something like "Confirm to delete [title of item]". Not sure if that would be sufficient.

avpaderno commented 1 month ago

What I find more confusing on these screenshots is the fact the tab/sub-tab is still showed as active.

screenshot

screenshot

When I deleted a node, the title is changed, but none of the visible tabs is shown as active.

screenshot

Should not what done by Backdrop core when deleting a node be always done when a confirmation page is shown?

avpaderno commented 1 month ago

When deleting a view from the page showing all the existing views, the tabs disappear.

screenshot

They disappear because the page changes from /admin/structure/views/list to /admin/structure/views/view/<view machine name>/delete and the latter does not have any tab. (In the case of nodes, the page changes from /node/<node ID>/edit to /node/<node ID>/delete.)

Even in this case, the title change is not confusing, since the page is clearly another one.

indigoxela commented 1 month ago

What I find more confusing on this screenshot is the fact the sub-tab is still showed as active.

@avpaderno is this something directly related to the change proposed here, or an independent (new) topic?

robertgarrigos commented 1 month ago

What @avpaderno is talking about has nothing to do with the changed proposed here. I just changed one backdrop_set_title() for a backdrop_set_message(). Tab functionality has not been changed.

avpaderno commented 1 month ago

@avpaderno is this something directly related to the change proposed here, or an independent (new) topic?

I am talking of the screenshots shown right after Proposed solution and in another comment (which shows the before-and-after changes), so yes, it is related to the change proposed here.

I am wondering if this is an issue with a contributed module because, as I shown in the screenshots attached to my previous comments, there is no issue with Backdrop core and the fact the page title is changed.

robertgarrigos commented 1 month ago

@avpaderno, yes, this is just how those contrib modules handle those tabs. Core's behavior is as you have shown, but again, this PR has nothing to do with how core or contrib modules handle the tabs, even I used them to explain the problem.

However, I got the point that I have to take a wider look at this issue, also, as @indigoxela pointed out, from an A11Y perspective. I agree that having just the same title is not clear enough. I'll try your suggestion of changing the title and printing the warning message as well.

robertgarrigos commented 1 month ago

Added the title keeping the warning:

Cursor_and_Confirm_deletion_of_post__test___My_Backdrop_Site_-_Vivaldi

indigoxela commented 1 month ago

Added the title keeping the warning:

Oh yes, better.

Of course, loads and loads of functional tests are failing, as they expect a different string for their checks. :wink: And phpcs also has something to nag - coding standards.

But let's see what people think re this UI change. Personally, I find this is an improvement, but I'm no UX specialist.

robertgarrigos commented 1 month ago

Fixed coding standards and failing tests

avpaderno commented 1 month ago

@avpaderno, yes, this is just how those contrib modules handle those tabs. Core's behavior is as you have shown, but again, this PR has nothing to do with how core or contrib modules handle the tabs, even I used them to explain the problem.

The issue is exactly how that contributed module handles tabs. It shows a confirmation form on the already rendered tab; that is why the page title changes.

It would not happen if the confirmation form would be rendered on a different page, which is what Backdrop core does with /node/<node ID>/delete.

With the provided PR, /node/<node ID>/delete is rendered as follows.

screenshot

I prefer how Backdrop renders /node/<node ID>/delete.

6a95e6e5f99efff9d6a531b2be5a65f8

argiepiano commented 1 month ago

The current PR assumes that confirm_form() is always used for deletion purposes (it hard-codes "Confirm deletion" as the title. This is not always the case. Confirm forms ARE used for other purposes.

For example, to confirm rebuilding permissions. Navigate to /admin/reports/status/rebuild and you'll see this erroneous and confusing page 👎🏽 :

Screen Shot 2024-10-25 at 6 43 24 AM

confirm_form has a myriad of other uses in contrib, that are not deletions.

Hard-coding titles in a function that is supposed to be agnostic of context is a "no-no" for me. In that same vein, using an if statement to check if the passed $form is that of a node is very limiting use of code, and also a "no-no" for me.

On the other hand I do agree about the ugliness of the UI before the PR.

robertgarrigos commented 1 month ago

good point, @argiepiano, I agree. Let's find a different approach. The simplest solution would be to set a fixed, agnostic of context, title, but very clear about what we are doing:

Confirm_action___My_Backdrop_Site_-_Vivaldi

Confirm_action___My_Backdrop_Site_-_Vivaldi

Confirm_action___My_Backdrop_Site_-_Vivaldi

No need of if statement either. Just two lines of code:

system_module_—_backhub

PR fixed with this approach.

argiepiano commented 1 month ago

OK, this is better, but keep in mind that system messages may be shown in a different spot of the layout (or even as a modal window that disappears after a certain amount of time, as is the case with some themes). So, we can't trust that the warning will always be shown in the "right" spot (below the title and above the button). This may confuse the user.

I feel like a system warning should not be used in this case - AFAIK system warnings are rarely used to prompt the user for some action (i.e. confirm something by clicking a button) - they are informational messages that are the results of an action.

Curious to hear others' feedback.

robertgarrigos commented 1 month ago

Another good point, @argiepiano, I agree. But I'll fix this ;-)

Confirm_action___My_Backdrop_Site_-_Vivaldi

Confirm_action___My_Backdrop_Site_-_Vivaldi

Confirm_action___My_Backdrop_Site_-_Vivaldi

These are not system messages. Note that there is no cross to close them in the upper right corner. They are form elements with prefix to shows as warning message and will not disappear:

system_module_—_backhub

Just pushed a commit with this fix.

klonos commented 1 week ago

I like the sentiment here, but would really prefer to have the confirmations thrown by confirm_form() replaced by a confirm_dialog() instead, which pops up a dialog instead of taking the user to another page/path. In other words, I would like us to do #3769 / #3771. That would be an awesome feature for 1.30 I think.

The good thing with such a solution is that users are not "redirected" somewhere else - they are kept within the same context of what they were doing.

robertgarrigos commented 5 days ago

This sounds a better solution, indeed.