Problem/Motivation
We're adding a search link to mobile devices.
Use story
As an anonymous user
I want a search link to be available on my mobile device
So that I can easily get to the search page
As a product owner of a website using CivicTheme
I want search on mobile to be available OOTB
So I don't have to customise my site to make it available
Acceptance criteria
Given I'm a site builder
When I set up my site
Then I can select whether the search link displays in the header or the menu on mobile devices
AC 1 - Link position
GIVEN I'm an anonymous user using a mobile device
WHEN I open the primary menu
THEN the search menu link and icon is available at the bottom of the menu
AND when I tap on the menu link I am taken to the search page
AC2 - Keyboard focus
GIVEN I'm an anonymous user
WHEN I use the tab key to move focus to a search input
THEN I see the button is focused using a visual indicator
THEN when I use the enter or spacebar key I am taken to the search page
AC3 - Mobile screenreader
GIVEN I'm an anonymous user
WHEN I use a mobile screenreader
AND I swipe to focus on a search input
THEN I hear its purpose is clear
AND I hear it identifies itself as a search input
AND I hear the form itself is discoverable with screenreader shortcuts as search landmark
AC4 - Site Administrator can control whether search block link appears in Mobile menu
Given I am a site administrator
When I am configuring my search block
Then I can select the search box to appear in the Mobile Menu
And the mobile menu will now contain a search link
Proposed resolution
@molecules/search/search.twig to show on mobile.
a. Remove the hide-xxs show-m-flex classes.
b. Set attributes with aria-label="Search" and check reads out correctly on screen readers.
c. In block config, place the mobile menu after search
d. Update the header theming to remove the position: absolute; top: 50%; transform: translateY(-50%); right: 0; from .ct-header .ct-mobile-navigation-trigger.
Add a field to /admin/structure/block-content/manage/civictheme_search/fields to "Show link in mobile menu".
In _civictheme_preprocess_block__civictheme_mobile_navigation:
a. Add query to get all blocks with the "Show link in mobile menu" selected
b. Use the link field in the search block to append a new link to the bottom of the mobile menu.
c. The new link added should also set an icon of magnifier.
In /mobile-navigation/mobile-navigation-menu.twig add the ability to have parameter items with an icon
a. Pass the icon parameter into the link.twig components. Icon should have a placement of before.
Add any additional styling, config or code cleanup.
| Comment | File | Size | Author |
|---|
Comments
Comment #2
fionamorrison23 commentedComment #3
fionamorrison23 commentedComment #8
fionamorrison23 commentedComment #9
danielgry commentedVerified and tested on latest dev version
Testing Results:
1. Verified the search link appears in the header on mobile as configured
2. Validated screen reader behaviour recognises the search button
3. Checked that the search placement is configurable in the Drupal backend
Screenshot:

Comment #10
danielgry commentedComment #11
richardgaunt commentedComment #13
richardgaunt commentedComment #14
fionamorrison23 commentedComment #15
fionamorrison23 commented