Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Right now users can use route:<nolink>
in order to create no-link links (see #2693725: Add <nolink> to allow for non-link links )
Proposed resolution
This issue tries to improve the UX allowing the user to enter into LinkWidget (URI) either <nolink>
<none>
to create no-link links.
As <front>
is special cased, so should be these.
Remaining tasks
Work on a patchAdding test coverageCover(split into #3015319: Add support for <current> to the LinkWidget UI<current>
case as well (see #29Update "User interface changes" IS section when point task above is done, if needed.(not needed)
User interface changes
The LinkWidget description for "generic" and "internal" now mentions the possibility of using <nolink>
to create no-linklinks.
API changes
None.
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#57 | 2698057-57.patch | 7.73 KB | idebr |
#57 | interdiff-51-57.txt | 958 bytes | idebr |
#26 | add_nolink_support-2698057-26--test-only.patch | 4.62 KB | gambry |
Comments
Comment #2
chx CreditAttribution: chx at Smartsheet commentedComment #3
dawehnerThis implementation seems reasonable. IMHO some integration test for the actual rendered menu link would be great, IMHO
Comment #4
Mac_Weber CreditAttribution: Mac_Weber as a volunteer commentedI added support for and also for empty values.
I think we should open a followup issue to make these special values to be accepted when set the option
External links only
is set forAllowed link type
at the field config, too.Comment #6
Mac_Weber CreditAttribution: Mac_Weber as a volunteer commentedThe empty value option needs more work to pass tests.
Comment #8
andypostComment #9
andypostfirst it needs to differentiate "empty" and "none" values and effect of "title" #2634232: In case of only 'link text' is required, then remove the required mark if the user deletes the text entered for URL
Comment #10
andypostComment #13
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI don't think we should support
""
. It's atypical for a menu link not to have a href, so more often than not I feel like it should trigger an error reminding people to enter something.<none>
or<nolink>
is a nice explicit decision.Comment #14
s_leu CreditAttribution: s_leu at Station commentedThere's a problem with the patch in 4: If you create a link field and let the default value of the url field empty, for some reason will be assumed as value. If this happens on a multivalue field, a second empty link field is printed in the entity form and the widget default value form, because the first default value containing is interpreted as value. If you do another save on the field settings page, another default value with is added etc.
This could probably be avoided by not interpreting empty values as nolink values, so +1 for the comment in #13.
Comment #15
idebr CreditAttribution: idebr at ezCompany commentedClosed #2880632: Allow 'link text' without 'URL' (URL optional) as a duplicate issue.
Comment #17
knyshuk.vova CreditAttribution: knyshuk.vova at Internetdevels, Drupal Ukraine Community commentedWe also should be able to use the routes and but we can't replace one from them to another. For example when I wish to display the link without url and I wish to use the Superfish module, than the mobile menu will be broken if I try to use . Using in this case work perfectly.
So, within the issue the admin should decide which router he want to use or .
Comment #18
knyshuk.vova CreditAttribution: knyshuk.vova at Internetdevels, Drupal Ukraine Community commentedComment #19
ryan.gibson CreditAttribution: ryan.gibson at Mediacurrent commentedTwo things in this patch:
1. Rerolled against 8.5.x dev.
2. Removed support for the empty string, which has been suggested and causes an issue described above.
Comment #20
ryan.gibson CreditAttribution: ryan.gibson at Mediacurrent commentedHere's the patch rerolled against 8.3.x dev. I also removed support for the empty string, which has been suggested and causes an issue described above.
Comment #22
ryan.gibson CreditAttribution: ryan.gibson at Mediacurrent commentedApologies, the patch from #20 had a missing bracket. Here is the 8.3.x dev patch resolved.
Comment #23
angelamnr CreditAttribution: angelamnr commented#22 works great! Thank you, ryanissamson! It would be nice to have help text, too, so that users know to use
<nolink>
. I made a patch for that.Comment #24
qzmenkoThanks, @angelamnr.
Patch #23 works great.
Comment #25
alexpottIn order to commit a bug fix we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:
@dawehner pointed this out in #3.
Comment #26
gambryAttached functional tests.
Also updating the IS because:
In these transitional periods I never know what the right D8 branch target is. Leaving 8.5.x just for the sake of running the tests, but I believe this should be 8.7.x .
Comment #29
JacineWhat about
<current>
? Can we add that here? If not, that's the only special case we leave unsupported.Comment #30
andypostTests already added
@Jacine the
<front>
already done, only none and nolink missingextended with *nolink*
Comment #31
JacineHi @andypost! :)
I'm asking about
<current>
, not<front>
. AFAICT, that's the only "special" one left from the list.Comment #32
andypostHey @Jacine sorry I misread( Yep - nice catch!
It would be great addition, btw It may affect caching
Comment #33
larowlanComment #34
gambrySo back to work in order to allow
<current>
Comment #35
gambryThis patch adds ability to use
<current>
special route in the Link widget, as well as<nolink>
,<none>
and<front>
.As I really don't see a use case for using this, and due the probable issue with cached versions of the rendered field, I have NOT mentioned
<current>
in the widget description/helper.This is currently still reading: "[...] Enter <front> to link to the front page. Enter <nolink> to display link text only."
Users can use the route, but as it's discouraged they can at their own risk. Thoughts?
Comment #36
Martijn de WitFor a time I used patch #26. With this patch I could use
<none>
in every Drupal menu. That works great btw :)Upgrade a develop site to use the latest patch #35. Now i encounter a problem: After I safe a menu item with it is now converted to
<nolink>
This come with a problem. However the menu item still doesn't have a menu link, at the front-page the menu item with
<none>
-> (converted to)<nolink>
is now an active link according to the system. So it get also the styling of an active menu link, what it of course not is.Using Drupal 8.6.3. Checked this behaviour not only in my custom theme also with Bartik
Comment #37
Martijn de WitOk it seems that there is an other issue for: https://www.drupal.org/node/2838351. Added it to related issues.
Comment #38
alexpottI think we should split
<current>
into its own issue. The caching side of that one makes it complex whereas<nolink>
and<none>
don't have this problem. Also the<nolink>
and<none>
are the 80%+ case.Comment #39
gambry@alexpott splitting makes sense.
Current patch is now #26. I'm createing the follow-up and link it here.
Also updating the title to remove
<current>
and reference to "empty values" (see #13 and #19 for why and when they have been excluded from the work).Comment #40
gambryCreated #3015319: Add support for <current> to the LinkWidget UI.
Comment #41
artematem CreditAttribution: artematem at FFW commentedUsed this patch on our project. Works as expected.
Comment #42
Wim LeersSorry, bunch of nits.
<current>
has not yet been removed per @alexpott's request in #38.s/array()/[]/
Also, could be made a strict check.
s/Text only/Text-only/
Nit: extraneous newline.
Comment #43
alexpottThis results in changing user input. I.e. if you enter
<none>
- I'm not sure of the difference betweennone
andnolink
but if there is a difference then this should maintained. Also swapping out user-input like this is not how we manage this elsewhere.Comment #44
alexpottRe #43 there's also a difference between how
none
andnolink
render.See...
Comment #45
Wim Leers#44: thanks, I was wondering about exactly that; I was wondering why they were being treated the same by #42.2.
Comment #47
Martijn de WitCreated a patch that can be applied to 8.8.x.
Didn't do anything with comment 44/45
Comment #48
Martijn de WitComment #49
Martijn de WitSorry, "needs work" to address comments from Alex and Wim.
Comment #50
idebr CreditAttribution: idebr at ezCompany commentedInterdiff for #35 -> #47
Comment #51
idebr CreditAttribution: idebr at ezCompany commented#42.1
<current>
was removed in #47, see interdiff in #50.#42.2 Applied short array notation, added strict parameter.
#42.3 Replaced 'Text only' with 'Text-only'
#42.4 Removed extraneous newline.
#43
<nolink>
and<none>
are now treated as separate values.Comment #52
Martijn de WitNice tweak Ide !
+1 :)
Comment #53
gambry#42 and #43 have been addressed, tests a green, looks RTBC to me. Thanks!!!
Comment #55
gambryFailure are not related, see #3055648: Frequent random fail in \Drupal\Tests\media_library\FunctionalJavascript\MediaLibraryTest . RTBCing again.
Comment #56
idebr CreditAttribution: idebr at ezCompany commentedThis description is incorrect:
route:<nolink>
is an internal link, so it will not be accepted as valid input.This description should therefore not be changed here.
Comment #57
idebr CreditAttribution: idebr at ezCompany commented#56 Removed the change to the field description for external link fields.
Comment #58
gambry@idebr the
<nolink>
route is neither external nor internal? Is a way for editors to display a no-link. The same reasons editor may have to requiring a no-link in a LINK_INTERNAL widget may be the same one may have in a LINK_EXTERNAL one?Comment #59
gambry@idebr I saw what you mean: from a validation point of view that can't be used. Shame, as a no-link link should be nice to have on both external and internal only widgets.
Maybe in a follow up? RTBCing for now, as to me doesn't look like a big blocker for what the issue is trying to achieve.
Comment #60
alexpottCommitted f4fbbd1 and pushed to 8.8.x. Thanks!
Comment #62
Wim LeersI think this might warrant a change record?
Comment #63
alexpott@Wim Leers yeah I debated that. The reason I ended up not asking for one if that the UI makes it clear that this is now allowed. And who has to update something as a result of this? I.e. what is there to change?
Comment #65
PasqualleI guess the menu link should be updated now #3062883: Unify nolink