Skip to content

Commit

Permalink
Merge pull request #9797 from alphagov/content-modelling/793-accessib…
Browse files Browse the repository at this point in the history
…le-autocomplete

content modelling/793 accessible autocomplete
  • Loading branch information
Harriethw authored Jan 10, 2025
2 parents 65d4b0d + ef8e2f5 commit 6b45cc8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
4 changes: 4 additions & 0 deletions app/views/components/docs/select_with_search.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Select with search
description: A dropdown select with search
body: |
NOTE: this component currently fails WCAG compliance for keyboard navigation, as the total number of options are not
announced when using Voice Over - the [autocomplete](./autocomplete.yml) component can provide same functionality and
meets the accessibility requirements.
Use this component to create a JavaScript-enhanced dropdown select.
It's powered by [Choices.js][], which is similar to [Select2][] but without the jQuery dependency.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,20 @@
} %>
<% end %>

<%= render "components/select_with_search", {
<%= render "components/autocomplete", {
id: "#{parent_class}_lead_organisation",
name: "content_block/edition[organisation_id]",
label: "Lead organisation",
include_blank: true,
options: taggable_organisations_container.map do |name, id|
{
text: name,
value: id,
selected: id == @form.content_block_edition.edition_organisation&.organisation_id,
}
end,
error_message: errors_for_input(@form.content_block_edition.errors, "lead_organisation".to_sym),
label: {
text: "Lead organisation",
},
select: {
multiple: false,
options: [""] + taggable_organisations_container,
selected: @form.content_block_edition.edition_organisation&.organisation_id,
},
autocomplete_configuration_options: {
showAllValues: true,
},
} %>

<%= render "govuk_publishing_components/components/textarea", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Feature: Edit a content object
@javascript
Scenario: GDS editor can preview a host document
When I revisit the edit page
And I fill out the form
And I save and continue
Then I am shown where the changes will take place
And I see the rollup data for the dependent content
When I click on the first host document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ def should_show_edit_form_for_email_address_content_block(document_title, email_
page.switch_to_window(page.windows.last)
assert_text "Preview email address"
assert_text "Instances: 1"
assert_text "Email address: [email protected]"
assert_text "Email address: #{@email_address}"
within_frame "preview" do
assert_text @current_host_document["title"]
end
Expand All @@ -642,7 +642,7 @@ def should_show_edit_form_for_email_address_content_block(document_title, email_
Then("I should see the content of the linked page") do
within_frame "preview" do
assert_text "other page"
assert_text "[email protected]"
assert_text @email_address
end
end

Expand Down

0 comments on commit 6b45cc8

Please sign in to comment.