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

Advanced link fields #16268

Merged
merged 8 commits into from
Dec 8, 2024
Merged

Conversation

brandonkelly
Copy link
Member

Description

Adds a new “Advanced Fields” setting to Link fields, where developers can choose which “advanced” fields they want to be available to authors. (Target and URL Suffix have both been moved into there.)

The new Advanced Fields setting

When any of them are selected, inputs will get an “Advanced” toggle, and each of the advanced fields will be hidden under it. (Collapsed by default.)

An expanded Link field

Related issues

Copy link

linear bot commented Dec 4, 2024

Copy link
Contributor

@gcamacho079 gcamacho079 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The “Advanced” toggle button can’t be operated via keyboard. This should use a button element with the following attributes: aria-expanded that toggles between true/false on expand/close, and an aria-controls value that references the ID of the advanced field container
  • URL type and value inputs should have explicit visible labels
  • The aria-describedby reference on the inputs with the “More info” doesn’t exist. For example, the following issue is found on the URL Suffix input: 'ARIA attribute element ID does not exist on the page: aria-describedby="fields-link1-url-suffix-instructions"'.
    In this case, I recommend adding an aria-hidden element in the heading or input container with the referenced ID and duplicating the instruction text inside. While it may cause some confusion that the instructions are hidden behind the tooltip and read as part of the input description, it’s a better experience than requiring users to navigate back to the toggle tip to access the instructions.
  • The input/heading containers require some extra padding when viewing at 320px
  • I noticed when I add a value to the URL Suffix input and save the entry, then return to the entry, the class, ID, and rel inputs end up with random values (see screenshot below).
Advanced attributes inputs. The URL suffix is filled with '#hello', and there are random character strings visible for the class, ID, and rel inputs.

@brandonkelly
Copy link
Member Author

@gcamacho079 Thanks! Addressed everything but the individual labels – that’s not a regression by this PR so we’ll address it separately.

[ci skip]
@brandonkelly brandonkelly merged commit 39e90e4 into 5.6 Dec 8, 2024
@brandonkelly brandonkelly deleted the feature/cms-1354-advanced-link-fields branch December 8, 2024 16:53
@alexanderbuergin
Copy link

Very cool! Thanks @brandonkelly

@Michael-Paragonn
Copy link

Love this! ❤️

But I have to ask; with Craft as dependent as it is on custom fields, it seems a bit incongruous to have these advanced fields be a limited assortment of "hard-coded" options. I mean, what you do have absolutely does make sense, it just begs the question of why there isn't a "custom field" type of option.

IRL use cases for custom fields on links:

  • Link style: Many times, a client will want to have the option to show a link in a button-style, rather than a "text link" style. It would simplify things if us developers could provide a dropdown field to select that on the link itself.
    image
  • Progressive enhancement: A link which goes to a "utility" page of some sort (login/register/search/subscribe/etc) by default, but if JS is enabled, the functionality of those pages gets loaded into a <dialog> instead.
  • Marketing: Typically it's more user-friendly to allow content authors to add marketing URL params in a visual manner instead of a technical one. Having them type out "?ref=campaign_name" in the URL suffix field is a technical approach; allowing them to select (via a Relationship field) the associated Campaign entry is a visual approach.

Taken to the "extreme", perhaps links could benefit from being Entry Types themselves?

@brandonkelly
Copy link
Member Author

@Michael-Paragonn Feel free to post that as a new discussion!

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

Successfully merging this pull request may close these issues.

4 participants