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

Workaround: jquery-apply aria-label to searchboxes #16

Merged
merged 1 commit into from
Nov 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/app/autosuggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'select2';

import 'select2/dist/css/select2.css';

function bindEquipmentInput(element, placeholder) {
function bindEquipmentInput(element, label, placeholder) {
$(element).select2({
ajax: {
url: 'api/equipment',
Expand All @@ -20,9 +20,12 @@ function bindEquipmentInput(element, placeholder) {
placeholder: placeholder,
selectOnClose: true
});

// TODO: Revisit once https://github.com/select2/select2/issues/3744 is handled
$(element).siblings('.select2').find('input[type=search]').attr('aria-label', label);
}

function bindIngredientInput(element, placeholder) {
function bindIngredientInput(element, label, placeholder) {
$(element).select2({
ajax: {
url: 'api/ingredients',
Expand All @@ -39,12 +42,15 @@ function bindIngredientInput(element, placeholder) {
placeholder: placeholder,
selectOnClose: true
});

// TODO: Revisit once https://github.com/select2/select2/issues/3744 is handled
$(element).siblings('.select2').find('input[type=search]').attr('aria-label', label);
}

$(function() {
bindIngredientInput('#include', 'e.g. tomatoes');
bindIngredientInput('#exclude', 'e.g. mushrooms');
bindEquipmentInput('#equipment', 'e.g. slow cooker');
bindIngredientInput('#include', 'Ingredients to include', 'e.g. tomatoes');
bindIngredientInput('#exclude', 'Ingredients to exclude', 'e.g. mushrooms');
bindEquipmentInput('#equipment', 'Kitchen equipment to use', 'e.g. slow cooker');

$(document).on('keyup', '.select2-search__field', function (event) {
if (event.keyCode == 13) {
Expand Down