mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-08 18:34:24 -04:00
Don’t filter ‘All of’ choice with live search
Because the ‘All of’ choice appears above the search field, it shouldn’t be filtered by the search field. We can fix this by wrapping the sub-areas in a `<div>` and make the selector more specific.
This commit is contained in:
@@ -22,9 +22,11 @@
|
||||
{{ form.select_all }}
|
||||
</div>
|
||||
|
||||
{{ live_search(target_selector='.govuk-checkboxes__item', show=show_search_form, form=search_form, label='Or by electoral ward') }}
|
||||
{{ live_search(target_selector='#sub-areas .govuk-checkboxes__item', show=show_search_form, form=search_form, label='Or by electoral ward') }}
|
||||
|
||||
{{ form.areas }}
|
||||
<div id="sub-areas">
|
||||
{{ form.areas }}
|
||||
</div>
|
||||
|
||||
{{ sticky_page_footer('Add to broadcast') }}
|
||||
|
||||
|
||||
@@ -468,21 +468,33 @@ def test_choose_broadcast_sub_area_page(
|
||||
'Choose an area of Aberdeen City'
|
||||
)
|
||||
live_search = page.select_one("[data-module=live-search]")
|
||||
assert live_search['data-targets'] == '.govuk-checkboxes__item'
|
||||
assert live_search['data-targets'] == '#sub-areas .govuk-checkboxes__item'
|
||||
assert live_search.select_one('input')['type'] == 'search'
|
||||
choices = [
|
||||
all_choices = [
|
||||
(
|
||||
choice.select_one('input')['value'],
|
||||
normalize_spaces(choice.select_one('label').text),
|
||||
)
|
||||
for choice in page.select('form[method=post] .govuk-checkboxes__item')
|
||||
]
|
||||
assert choices[:3] == [
|
||||
sub_choices = [
|
||||
(
|
||||
choice.select_one('input')['value'],
|
||||
normalize_spaces(choice.select_one('label').text),
|
||||
)
|
||||
for choice in page.select('form[method=post] #sub-areas .govuk-checkboxes__item')
|
||||
]
|
||||
assert all_choices[:3] == [
|
||||
('y', 'All of Aberdeen City'),
|
||||
('wd20-S13002845', 'Airyhall/Broomhill/Garthdee'),
|
||||
('wd20-S13002836', 'Bridge of Don'),
|
||||
]
|
||||
assert choices[-1:] == [
|
||||
assert sub_choices[:3] == [
|
||||
('wd20-S13002845', 'Airyhall/Broomhill/Garthdee'),
|
||||
('wd20-S13002836', 'Bridge of Don'),
|
||||
('wd20-S13002835', 'Dyce/Bucksburn/Danestone'),
|
||||
]
|
||||
assert all_choices[-1:] == sub_choices[-1:] == [
|
||||
('wd20-S13002846', 'Torry/Ferryhill'),
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user