From 67d3beebded6ba91e7a37f042c87ed087c63fdfa Mon Sep 17 00:00:00 2001 From: Ryan Laddusaw Date: Wed, 23 Oct 2024 16:07:20 -0400 Subject: [PATCH] Saving size selection when changing floor selection --- app/javascript/components/locker_size_filter.js | 2 ++ spec/features/locker_application_new_spec.rb | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/app/javascript/components/locker_size_filter.js b/app/javascript/components/locker_size_filter.js index 2787f61..06e6aef 100644 --- a/app/javascript/components/locker_size_filter.js +++ b/app/javascript/components/locker_size_filter.js @@ -15,6 +15,7 @@ export default class LockerSizeFilter { #addListener() { this.preferredFloor.addEventListener('change', () => { if (this.library === 'Firestone') { + const selectedFloor = this.preferredSize.value; if (this.preferredFloor.value === 'A floor') { this.preferredSize.options.length = 0; this.preferredSize[0] = new Option('6-foot', 6); @@ -22,6 +23,7 @@ export default class LockerSizeFilter { this.preferredSize.options.length = 0; this.preferredSize[0] = new Option('4-foot', 4); this.preferredSize[1] = new Option('6-foot', 6); + this.preferredSize.value = selectedFloor; } } }); diff --git a/spec/features/locker_application_new_spec.rb b/spec/features/locker_application_new_spec.rb index 69efe8a..ad0f1c4 100644 --- a/spec/features/locker_application_new_spec.rb +++ b/spec/features/locker_application_new_spec.rb @@ -118,6 +118,15 @@ new_application.reload expect(new_application.accessibility_needs).to contain_exactly('Keyed entry (rather than combination)') end + + it 'keeps the selected locker size when selecting floor' do + visit root_path + select('Firestone Library', from: :locker_application_building_id) + click_button('Next') + select('6-foot', from: :locker_application_preferred_size) + select('C floor', from: :locker_application_preferred_general_area) + expect(page).to have_select('Preferred Size', selected: '6-foot') + end end context 'with lewis_patrons off' do