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

[4.x]: BaseMultiSelectConditionRule mutates "New" option in select list #11946

Closed
nfourtythree opened this issue Sep 15, 2022 · 1 comment
Closed

Comments

@nfourtythree
Copy link
Contributor

What happened?

Description

When extending the BaseMultiSelectCondtionRule if there is a set of selectable options that include 'new' => 'New' the output of this value is mutated and an add icon is added.

Craft CMS version

4.2

PHP version

8.0

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

No response

@brandonkelly
Copy link
Member

Here’s the culprit:

body .selectize-dropdown-content > div[data-value='new']:before {
@include icon;
content: 'plus';
margin-right: 5px;
}
body .selectize-dropdown-content > div[data-value='new']:after {
content: '';
}

We’re not actually taking advantage of that anywhere in core, but it’s being used by Commerce, e.g. when creating a new tax rate:

The Tax Category setting when creating a new tax rate in Craft Commerce. The input is a Selectize menu, currently expanded, with “General” and “New tax category…” options.

I’m going to remove those styles in Craft 5. Anything still taking advantage of them should switch over to the _includes/forms/selectize.twig template (or craft\helpers\Cp::selectizeHtml() / selectizeFieldHtml()), and pass addOptionFn and addOptionLabel values to it. (See the _includes/forms/fs.twig template for an example.)

In the meantime, you will need to try to avoid using new as an option value. Ideally, a UID could be used instead, as handles can be fickle.

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

2 participants