Node edit form: "No tour" but there is a tour

Created on 5 November 2024, about 2 months ago

Problem/Motivation

Creating a tour that is available when both Adding and Editing a node of a certain type/bundle. The Toolbar says "Tour" when adding a node of that type, but "No Tour" when editing such a node. In both cases, clicking on the tour button starts the tour.

Steps to reproduce

Install Tour 2.0.6 on Drupal 10.3.6. Create a tour that is configured for a node bundle (I've chosen 'page') using the following Routes ...

node.add
- node_type:page
entity.node.edit_form
- bundle:page

Go to the Add Node page for "Pages". The toolbar says "Tour" and clicking that button starts the tour.

Edit a node of that bundle. The toolbar says "No Tour" but clicking that button starts the tour anyway.

Proposed resolution

Debugging when the route is 'entity.node.edit_form' ...

  • This route has a parameter 'node' that is the Node entity being edited
  • tour_page_bottom() discovers this at line 167 of tour.module and sets $params['bundle'] to the node's bundle. This allows the route to be matched so the tour can be added to $page_bottom. This explains why the tour is available when the toolbar button is clicked.
  • On the other hand, tour_toolbar() only looks at the 'node' parameter's id() on line 94, so $no_tips is set TRUE. Then when the button is rendered LazyBuilders::renderTour() sets the text to "No tour".

Remaining tasks

My innocent presumption is that tour_toolbar() should follow the same logic as tour_page_bottom(). In fact it seems wasteful that both functions do an entityQuery('tour') - could the query be run once and the results stashed?

User interface changes

Nil

API changes

Nil

Data model changes

Nil

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia kenwest

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024