This issue pertains to the single-page New View configuration: Admin > Structure > Views > Add View. Remain on this page.

  1. In Drupal 8.8.1, when creating a new view from the single-page configuration,
  2. Tick the Create a Page checkbox (which exposes a Path text field.
  3. Enter a path incorrectly, with a leading slash (ie. `/test` instead of just `test`).
  4. Click to Save and Edit the new view.

Outcome: The resulting new View edit screen shows the path entered with an additional, leading slash (`//test`)
Instead: The path shown should have been stripped down to no leading path but shown with a single leading path in the UI.

This stands out as odd/incorrect, because, by contrast, an attempt to define a path with leading slash via the View Edit UI (not the single page) will automatically (and correctly) manage that leading slash as it should.

This is inconsistent. Instead, the same path Views values validation should occur on intake of Create View form/wizard screen that occurs during view Edit.

Screenshot of double-slash path in View

The view can be saved in this state, but the page view URL works fine -- no major harm that I could tell.

Workaround: subsequent edits to the field will do the necessary validation and adjustment for the user.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

texas-bronius created an issue. See original summary.

texas-bronius’s picture

Title: Views: Create Views: Enable page, set path with leading slash (/), slash is not removed as it is when editing the path on existing view edit screen » Views: Create Views: Enable page, set path with leading slash (/), slash is not validated as it is when editing the path on existing view edit screen and ends up with a double-slash (//)

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

Drupal 8.7.9 was released on November 6 and is the final full bugfix release for the Drupal 8.7.x series. Drupal 8.7.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.8.0 on December 4, 2019. (Drupal 8.8.0-beta1 is available for testing.)

Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.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.

revati_gawas’s picture

Validated page path on creating new page view itself to get proper path on edit page view also. Additional leading slash will be automatically removed. Please check attached patch

revati_gawas’s picture

Status: Active » Needs review
texas-bronius’s picture

Status: Needs review » Reviewed & tested by the community

It scratches the itch, checks the box, I've tested and confirm it does overcome what I had reported without introducing anything new and unexpected. Thanks for having a look and coming up with an easy solution!

What my testing doesn't do is assess whether this should be a different sort of fix: Rather than checking for and stripping the leading slash (/), another solution would be to extend whatever is validating the field in the View Edit > Page > Path field: It has a funny behavior as is that if it has a value, it will _display_ a leading slash in the field view, but when it is being _edited_, there is no leading slash. Further, if the user enters a single leading slash, the form removes it from the submitted value (but still displays it). If the user enters two or more leading slashes, the UI prevents the form from being submitted with a validation error on allowed characters. If it is deemed worth pursuing, I think it would be more prudent to reuse the same behavior in both places.

Lendude’s picture

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

I cannot reproduce this problem on 8.8 or 8.9

Before this is RTBC we need an automated test for this to prove that this is an existing issue and that the proposed patch fixes this.

texas-bronius’s picture

Issue summary: View changes
Lendude’s picture

Title: Views: Create Views: Enable page, set path with leading slash (/), slash is not validated as it is when editing the path on existing view edit screen and ends up with a double-slash (//) » When creating a Page View in the wizard and setting a path with leading slash (/) the created View display ends up with a double-slash (//)

Ahh I totally read over the part where this only happens when you create a new page display with the new View wizard, sorry.

Totally reproducable.

Lendude’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
FileSize
2.06 KB
1.42 KB
2.33 KB

Re #6: yes it is weird behaviour, but all comes back to #2423913: Leading slash in link fields and views has different UX. There are todo's spread about Views for that, so let's keep the comment here in line with that.

Added a test and the fix from #4, just updated the comment.

Lendude’s picture

Stray extra whitespace

The last submitted patch, 10: 3065720-10-TEST_ONLY.patch, failed testing. View results

texas-bronius’s picture

Status: Needs review » Reviewed & tested by the community

Nice! I see the automated test passed, and I have applied the patch and seen it do its thing. Can I set it to RTBC myself?

I appreciate the work that went into making this tiny fix, and I appreciate your taking the time to explain that it's less of a fix and more of a workaround. It's a very exclusive, one-use-case solution :) but it does the job! Is is not more appropriate to use the same field widget as the link module for this Create View "wizard" form?

Lendude’s picture

Can I set it to RTBC myself?

If you feel it is ready, then yes, absolutely! Thank you!

Is is not more appropriate to use the same field widget as the link module for this Create View "wizard" form?

It would be nice, but that is not how the wizard is build up. It's all custom stuff, so using field widgets would require massive refactoring.

alexpott’s picture

We're doing a lot of $form_state->getValues() and that's not necessary.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 6ae9811c48 to 9.0.x and 8274945514 to 8.9.x and 422b35077f to 8.8.x. Thanks!

Backported to 8.8.x since this is nice bugfix with test coverage.

  • alexpott committed 6ae9811 on 9.0.x
    Issue #3065720 by Lendude, alexpott, revati_gawas, texas-bronius: When...

  • alexpott committed 8274945 on 8.9.x
    Issue #3065720 by Lendude, alexpott, revati_gawas, texas-bronius: When...

  • alexpott committed 422b350 on 8.8.x
    Issue #3065720 by Lendude, alexpott, revati_gawas, texas-bronius: When...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.