Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "None" as a link type option #8

Open
engram-design opened this issue Feb 16, 2023 · 9 comments
Open

Add "None" as a link type option #8

engram-design opened this issue Feb 16, 2023 · 9 comments

Comments

@engram-design
Copy link
Member

engram-design commented Feb 16, 2023

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.

@Antimated
Copy link

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
Copy link

gglnx commented Mar 5, 2023

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.

@engram-design
Copy link
Member Author

@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.

@Antimated
Copy link

Antimated commented May 24, 2023

@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.

@engram-design
Copy link
Member Author

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.

@chrismlusk
Copy link

@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!

@engram-design
Copy link
Member Author

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.

@samuelreichor
Copy link

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

@engram-design
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants