verbb/hyper

Add "None" as a link type option

engram-design opened this issue ยท 10 comments

At the moment, for a new element the field will auto-create a new link block with the set default link type. That might be URL, Entry, etc - it'll just be empty. There's no issue with content validation, you'll just end up with an empty link type.

For clarity, it might be better to allow users to use (and set the default) to a "None" option.

What's challenging about this is the UI - how to make it look like it's an empty field without making it look "broken".

Option 1

image

There's a part of me that feels this looks "broken", as there are no options available. You can also click the "New Window" and settings icons, which isn't great if you haven't picked a type yet.

Option 2

image

We remove the block layout altogether and ask the user to pick a new link type. This is the same behaviour as a multi-link fields. The downside to this is it makes the default link type essentially useless.

Probably something like this would look ok. I wonder how this would work if you have multiple links tho, as in what data would be returned if the link is set to "None". Should probably just not get returned into the eventual data?

Screenshot 2023-03-01 at 09 32 54

gglnx commented

I would prefer option 2, because it's reducing the visual clutter and is more aligned with other field types (Matrix, Relationships). As for the default link type: Why not add 'None' to the type dropdown? If I select a type other than 'None' one record with this link type will be created on initialization.

@Antimated The value for "None" would likely be null. We'd want to introduce this behaviour soon-ish, because it's a breaking behaviour. Currently, we return an empty Link object, and templates would need updating to reflect the check for null.

@gglnx And yep, that's pretty much what I was thinking. Typically, you'd set the default link type to "None", which if you did, you'd see the dropdown link-type-picker to pick a link type to add. If you wanted to set the default link type to "Entry" it would behave exactly as it does now - loading up an empty entry link type.

So 1 point each at the moment ๐Ÿ˜… @Mosnar you might have to be the tie-breaker.

@engram-design Any updates on this? We are starting to use this plugin more and more, and this feature would really benefit the client's user experience.

Still just getting people's opinions on this one, but as there haven't been too many people bringing this up (just the 3 of you), I haven't felt it's a massive concern for people.

At this stage, due to the change of behaviour where links would return null instead of an empty Link object as it does now, it'd be a breaking change for a major release. At this stage, timing-wise, it'd probably tie in with Craft 5.

@engram-design if a change hasn't already been decided on, I'll add my vote for option 2. And now there are four whole people!

We'll be introducing this change in Hyper 2 for Craft 5, and we'll probably go with Option 2, where the only thing you see on a new entry when there are no values is the add-link button (similar to Matrix).

Shifting to Hyper 2 due to the breaking change introduced in the value for the field, as we'll introduce a "None" link option that would return null as opposed to a Link object. This is a more preferable option to returning a model or object, so that users can effectively test whether a (single) link field is empty.

I'm still undecided about how to handle the default link type however, so we'll be workshopping that.

@engram-design We are planning to use Hyper in production now and would like to know approximately when Hyper 2 will be released :)

@samuelreichor Should be in the next month or so! Just going to finalise any breaking changes in the meantime.

Is this still in the works? I just tested Hyper v2.0.4 on Craft 5 and I'm not seeing this option. This feature is really needed before I can use this plugin in production. My frequent use case for many clients is an optional button that requires link text when the button is used.