Browse Source

Set default option on accessile autocomplete

pull/778/head
baarkerlounger 3 years ago
parent
commit
d955c72963
  1. 2
      app/frontend/controllers/accessible_autocomplete_controller.js
  2. 2
      spec/features/user_spec.rb

2
app/frontend/controllers/accessible_autocomplete_controller.js

@ -13,7 +13,7 @@ export default class extends Controller {
const rawFieldName = matches ? `${matches[1]}[${matches[2]}_raw]` : ''
accessibleAutocomplete.enhanceSelectElement({
defaultValue: '',
defaultValue: options[0].name,
selectElement: selectEl,
minLength: 1,
source: (query, populateResults) => {

2
spec/features/user_spec.rb

@ -630,7 +630,7 @@ RSpec.describe "User Features" do
it "clears the previously selected organisation value" do
visit("/logs")
choose("organisation-select-specific-org-field", allow_label_click: true)
expect(page).to have_field("organisation-field", with: "")
expect(page).to have_field("organisation-field", with: "Select an option")
find("#organisation-field").click.native.send_keys("F", "i", "l", "t", :down, :enter)
click_button("Apply filters")
expect(page).to have_current_path("/logs?%5Byears%5D%5B%5D=&%5Bstatus%5D%5B%5D=&user=all&organisation_select=specific_org&organisation=#{organisation.id}")

Loading…
Cancel
Save