This issue pertains to the single-page New View configuration: Admin > Structure > Views > Add View. Remain on this page.
- In Drupal 8.8.1, when creating a new view from the single-page configuration,
- Tick the Create a Page checkbox (which exposes a Path text field.
- Enter a path incorrectly, with a leading slash (ie. `/test` instead of just `test`).
- 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.
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.
Comment | File | Size | Author |
---|---|---|---|
#15 | 3065720-15.patch | 2.28 KB | alexpott |
#15 | 11-15-interdiff.txt | 1.01 KB | alexpott |
#11 | 3065720-11.patch | 2.33 KB | Lendude |
#11 | interdiff-3065720-10-11.txt | 664 bytes | Lendude |
#10 | 3065720-10.patch | 2.33 KB | Lendude |
Comments
Comment #2
texas-bronius CreditAttribution: texas-bronius commentedComment #4
revati_gawasValidated 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
Comment #5
revati_gawasComment #6
texas-bronius CreditAttribution: texas-bronius commentedIt 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.
Comment #7
LendudeI 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.
Comment #8
texas-bronius CreditAttribution: texas-bronius commentedComment #9
LendudeAhh 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.
Comment #10
LendudeRe #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.
Comment #11
LendudeStray extra whitespace
Comment #13
texas-bronius CreditAttribution: texas-bronius commentedNice! 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?
Comment #14
LendudeIf you feel it is ready, then yes, absolutely! Thank you!
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.
Comment #15
alexpottWe're doing a lot of $form_state->getValues() and that's not necessary.
Comment #16
alexpottCommitted 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.