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-7158: As an Editor, I'd like to have shortcut for search focus #1006

Merged
merged 2 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@
removeClickOutsideEventListener();
removeKeyboardEventListener();
};
const focusSearch = (event) => {
if (event.shiftKey && event.code === 'Slash') {
globalSearchInput.focus();
}
};

globalSearchInput.addEventListener('keyup', handleTyping, false);
clearBtn.addEventListener('click', hideAutocomplete, false);
doc.addEventListener('keyup', focusSearch, false);
})(window, document, window.ibexa, window.Routing, window.Translator);
21 changes: 21 additions & 0 deletions src/bundle/Resources/public/scss/_global-search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@
&::placeholder {
color: $ibexa-color-light;
}

&:focus {
& ~ .ibexa-global-search {
&__shortcut {
display: none;
}
}
}
}

&__autocomplete-no-results {
Expand Down Expand Up @@ -217,4 +225,17 @@
}
}
}

&__shortcut {
display: inline-block;
line-height: calculateRem(16px);
font-size: calculateRem(12px);
padding: 0 calculateRem(4px);
background-color: $ibexa-color-info-700;
border-radius: calculateRem(4px);
font-weight: 400;
dew326 marked this conversation as resolved.
Show resolved Hide resolved
position: absolute;
bottom: calculateRem(1px);
right: calculateRem(100px);
}
}
5 changes: 5 additions & 0 deletions src/bundle/Resources/translations/ibexa_search.en.xliff
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<target state="new">View all results</target>
<note>key: autocomplete.view_all_results</note>
</trans-unit>
<trans-unit id="75d6d16d28be17ef015b223c19696f17e99f2be3" resname="global_search.focus.hint">
<source>Press `Shift` + `/` to focus</source>
<target state="new">Press `Shift` + `/` to focus</target>
<note>key: global_search.focus.hint</note>
</trans-unit>
<trans-unit id="7100bfb6741e032fcfcc681f3eceef78650e4672" resname="header.search">
<source>Search...</source>
<target state="new">Search...</target>
Expand Down
12 changes: 12 additions & 0 deletions src/bundle/Resources/views/themes/admin/ui/form_fields.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@
{%- endblock -%}

{%- block _search_query_widget -%}
{% trans_default_domain 'ibexa_search' %}

{% set has_search = true %}
{%- set extra_content -%}
<div class="ibexa-global-search__shortcut">
{{ 'global_search.focus.hint'|trans|desc('Press `Shift` + `/` to focus') }}
</div>
{%- endset -%}

{{ block('form_widget_simple') }}
{%- endblock -%}
Expand Down Expand Up @@ -395,6 +402,11 @@
{% block content %}
{{ input_html }}
{% endblock %}
{% block extra_content %}
{% if extra_content is defined %}
{{ extra_content }}
{% endif %}
{% endblock %}
{%- endembed -%}
{%- else -%}
{{ parent() }}
Expand Down
Loading