Skip to content

ENH: Streamline link creation if only one type of link is allowed#420

Merged
GuySartorelli merged 2 commits intosilverstripe:5from
DanielHurdMint:feat-skipping-dropdown-select-with-one-link-type-option
Dec 16, 2025
Merged

ENH: Streamline link creation if only one type of link is allowed#420
GuySartorelli merged 2 commits intosilverstripe:5from
DanielHurdMint:feat-skipping-dropdown-select-with-one-link-type-option

Conversation

@DanielHurdMint
Copy link
Copy Markdown
Contributor

@DanielHurdMint DanielHurdMint commented Nov 9, 2025

Adding a memoized variable with the pre-filtered allowedTypes, updating toggle function to return early and select the first item in the allowedTypes array if only one exists. Updating returned react to exclude caret when only one link type is applicable, using allowedTypes array in the dropdownmenu map

Description

Updating the link creation process to be more streamlined as per this issue: #185

Issues

Manual testing steps

With either a LinkField or MultiLinkField, set the allowedTypes to a single type - you will then notice the caret will be hidden and upon clicking the button, the modal will appear directly

Example code:

LinkField::create('Button')->setAllowedTypes([SiteTreeLink::class]);
MultiLinkField::create('Button')->setAllowedTypes([SiteTreeLink::class]);

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

…ng toggle function to return early and select the first item in the allowedTypes array if only one exists. Updating returned react to exclude caret when only one link type is applicable, using allowedTypes array in the dropdownmenu map
@GuySartorelli
Copy link
Copy Markdown
Member

Hi there,

Thanks for submitting this. I have added the checklist back into the PR description - please don't remove it. It's there for you as the contributor to tick off the boxes that apply. If you don't think you should tick one of the boxes that's usually an indication that you need to do something - in this case I have left several boxes unticked (e.g. the commit message doesn't meet our guidelines, and CI isn't passing).

Can you please tidy up the PR by fixing the commit message, resolving the CI failure, and updating the tests to cover this new scenario?

@DanielHurdMint DanielHurdMint changed the title Streamline link creation if only one type of link is allowed NEW: Streamline link creation if only one type of link is allowed Nov 18, 2025
@DanielHurdMint DanielHurdMint changed the title NEW: Streamline link creation if only one type of link is allowed ENH: Streamline link creation if only one type of link is allowed Nov 18, 2025
@DanielHurdMint
Copy link
Copy Markdown
Contributor Author

@GuySartorelli
Hi Guy,

Sorry for the delay with making changes to the PR, I have fixed everything up and it is now passing clean

If you would like me to make any further revisions, please let me know

Thanks,
Daniel

Copy link
Copy Markdown
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

Thanks for this! Works as expected locally. Great work!

@GuySartorelli GuySartorelli merged commit a00396f into silverstripe:5 Dec 16, 2025
14 checks passed
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.

2 participants