-
Notifications
You must be signed in to change notification settings - Fork 63
Use links instead of buttons for header search type switcher #1131
Conversation
c5a2889
to
1c25a5b
Compare
0ab1557
to
710e40c
Compare
# Conflicts: # src/locales/po-files/openverse.pot
@@ -46,6 +47,10 @@ export default defineComponent({ | |||
required: true, | |||
validator: (val) => supportedSearchTypes.includes(val), | |||
}, | |||
placement: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I mentioned earlier, I think a name that indicates the internal component behavior is better than one that refers to the external context. placement
might be better as useLinks
or some better name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works really well! I made some optional suggestions to code style but otherwise lgtm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I wrote a comment last week and then forgot to submit this review, sorry! Zack mentioned something similar and probably better, just using a specific prop name instead of something contextual! Easier to test in Storybook that way as well 🙂 Kudos Zack!
@@ -30,16 +33,33 @@ const propTypes = { | |||
itemId: { type: Number, required: true }, | |||
selected: { type: Boolean, default: false }, | |||
icon: { type: String, required: true }, | |||
isInHeader: { type: Boolean, default: true }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This props like these I always wonder whether continue to drill them down or switching to using provide/inject
would make more sense. I guess this is probably easier to test. It also crosses my mind "at what point does one decide to turn the enum into a boolean" in this case. For example, why pass the boolean here instead of passing placement directly which can then be evaluated by the component?
I don't have good answers for these though 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this comment, @sarayourfriend ! I have also thought about replacing props drilling with provide/inject
, but decided against it for one single prop.
Co-authored-by: Zack Krida <zackkrida@pm.me>
Fixes
Fixes #1130 by @obulat
Note: This PR works for adding links that retain common filter query parameters, but for correctly handling the search type specific query parameters it is dependent on #1040 (it needs an action that is only available in that PR). Since these two PRs are interdependent, it is best to approve and merge them together, or add
TODO
into another PR once one of them is merged.Description
This PR makes the search type switcher use
VLink
when used in the header, and keep the current button status when used in the homepage searchbar.This makes the header links more semantic (and also sets the
aria-current="page"
for the link to currently selected search type), and simplifies the search type handling.It also fixes the e2e tests that are failing in #1040, and are currently disabled.
Testing Instructions
Run the app using
pnpm dev
, search for something from the homepage.Switching search type from the homepage search bar should work as usual, and should not redirect to another page, because it's not using an
<a>
link.Selecting a search type from the header should redirect you, as usual, and update the url path. You can see in the devtools that the search type switcher is using
<a>
links.Currently, the link will only retain the filter query parameters that are common for all search types (license, license types, search by creator).
After the search store change is merged, You should also see that the query in those links retains the filter parameters that that type can use, and removes the parameters that are not appropriate. For example, if on the image page you check the 'jpg' file type filter and 'cc0' license filter, the link to 'all_content' type should only contain 'cc0' in the parameter, and discard the 'jpg' parameter.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin