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

IBX-1674: Empty select option for dropdown #109

Merged
merged 4 commits into from
Dec 16, 2021
Merged

Conversation

GrabowskiM
Copy link
Contributor

@GrabowskiM GrabowskiM commented Dec 10, 2021

value: '{{ value }}',
label: '{{ label }}',
})|e('html_attr') }}"

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@GrabowskiM GrabowskiM force-pushed the IBX-1674-empty-select branch from 09dcba9 to f452baf Compare December 10, 2021 14:53
{% set custom_form = custom_form is defined ? custom_form : true %}
{% set translation_domain = translation_domain|default(false) %}
{% set value = value is defined ? value : null %}
{% set multiple = multiple is defined ? multiple : false %}
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick question: why not just multiple|default(false)?

{% set placeholder = placeholder|default(default_placeholder) %}
{% set label = placeholder %}

{{ _self.get_translated_label(placeholder, translation_domain )}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't you translating the placeholder twice? It looks like:

  1. you assign translated label to default_placeholder
  2. you pass it as placeholder to get_translated_label where it is translated again when translation_domain is not false.

I guess that from the backend you are getting a placeholder that is not translated?
I'm also not sure whether we need get_translated_label as a separate macro for such a small thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On one hand it's small thing, but it's used in five different places, its shorthand if, etc., I think it looks neater with macro

<li class="ibexa-dropdown__selected-item ibexa-dropdown__selected-item--predefined ibexa-dropdown__selected-overflow-number" hidden></li>
</ul>
<div class="ibexa-dropdown__items">
{% if choices_flat|length >= min_search_items %}
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder, wouldn't it be better to hide search with CSS class? Then you can always change decision in JS.

@GrabowskiM GrabowskiM force-pushed the IBX-1674-empty-select branch from 37397b3 to e9fd9a6 Compare December 16, 2021 12:08
{% endmacro %}

{% macro get_translated_placeholder(placeholder, translation_domain) %}
{% if placeholder is defined %}
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you pass a variable that is not defined (in this case placeholder) to a macro?

Copy link
Contributor

Choose a reason for hiding this comment

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

You cannot, as discussed in private :)

@GrabowskiM GrabowskiM force-pushed the IBX-1674-empty-select branch from e9fd9a6 to 5f600cd Compare December 16, 2021 13:52
@dew326 dew326 merged commit 48d9117 into main Dec 16, 2021
@dew326 dew326 deleted the IBX-1674-empty-select branch December 16, 2021 14:27
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