-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve search modal results [FC-0040] #946
feat: improve search modal results [FC-0040] #946
Conversation
Thanks for the pull request, @rpenido! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
5fc9b54
to
21e7cab
Compare
bb31469
to
6230900
Compare
6230900
to
14ded36
Compare
|
||
div.row:has(> div > div.highlight) { | ||
animation: 5s glow; | ||
} | ||
|
||
@keyframes glow { | ||
0% { | ||
box-shadow: 0 0 5px 5px $primary-500; | ||
} | ||
|
||
90% { | ||
box-shadow: 0 0 5px 5px $primary-500; | ||
} | ||
|
||
100% { | ||
box-shadow: unset; | ||
} | ||
} |
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 is the animation after scrolling to a searched component. Personally, I didn't like it. 😞
I am open to suggestions! @ali-hugo
PS: The highlight only happens if the parent item is expanded and the component is on screen. We could improve it with a follow-up task.
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.
@rpenido I agree that the scrolling is awkward.. but I can't think of a better place to send someone who's searched for a Section/Subsection.
However, if they search for a Unit, I think we should direct them to the Unit edit page instead of scrolling down the outline, because Units are very unlikely to be expanded on that page. So then it's just Sections and Subsections that use the scrolling thing, and Units and components redirect to the Unit edit page.
@ali-hugo What do you think?
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.
The Unit redirect will be fixed in a follow-up task!
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.
What seems to be the issue with the animation? I think one thing that can be done to make it smoother is to use a timing function.
i.e. remove the 90% step and add a timing function like:
animation-timing-function: cubic-bezier(1,0,.72,.04);
This will be a lot smoother I think since it'll follow a curve rather than a steep fall.
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.
What seems to be the issue with the animation?
Nothing specific. I just didn't find it "wow" (I'm not sure if it was the color, the glow size..). I think it's a subjective feeling, and I'm open to options to improve it (if that's the case).
Changed the curve here: 12ba0c5
} | ||
|
||
navigate(url); | ||
closeSearch?.(); |
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.
I had to pass the closeSearch
function down the path SearchModal > SearchEndpointLoader > SearchUI > SearchResult
to close the modal. Maybe we should add a context to handle this state?
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.
Is that how our other modals work? If so, then yes, I agree that's worth doing here too.
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.
We don't have this problem in the other modals because we don't have a deep inner component interacting with it.
The current approach is the simple-but-not-so-beauty way. We could hear more from cc/upstream review if we can improve it without adding complexity.
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.
I added it to a context in my PR when I merged it with this one - see here.
declare module '*.svg' { | ||
const content: string; | ||
export default content; | ||
} |
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.
To support importing svg
files as image source
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.
Hi @rpenido , this is looking and working beautifully! I found a couple of minor nits and a couple of omissions from the Figma designs, noted inline.
src/search-modal/SearchResult.jsx
Outdated
const { context_key: contextKey, usage_key: usageKey } = hit; | ||
if (contextKey.startsWith('course-v1:')) { | ||
if (newWindow) { | ||
return `${getPath(getConfig().PUBLIC_PATH)}/course/${contextKey}?show=${encodeURIComponent(usageKey)}`; |
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.
getPath
returns a trailing /
, so this link ends up with //course/
in the path, and fails to load.
return `${getPath(getConfig().PUBLIC_PATH)}/course/${contextKey}?show=${encodeURIComponent(usageKey)}`; | |
return `${getPath(getConfig().PUBLIC_PATH)}course/${contextKey}?show=${encodeURIComponent(usageKey)}`; |
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.
Also, since these returned URLs share a common path string, can that be reflected in the code too?
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.
And finally: Figma says that when we click on a component (text, video, etc), we should be directed to the Unit edit page with the component highlighted. instead of just trying to scroll down to the Unit in the outline.
(I also think searching for a Unit should take us to the Unit edit page too, but that's up to UI/UX, see above :)
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.
Also, since these returned URLs share a common path string, can that be reflected in the code too?
Sure! Done here: 53d70e3
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.
And finally: Figma says that when we click on a component (text, video, etc), we should be directed to the Unit edit page with the component highlighted. instead of just trying to scroll down to the Unit in the outline.
Ack! We will need a follow-up task to that because right now, we don't have the unit info in the component result.
src/search-modal/SearchResult.jsx
Outdated
return `/course/${contextKey}?show=${encodeURIComponent(usageKey)}`; | ||
} | ||
if (usageKey.includes('lb:')) { | ||
return `${libraryAuthoringMfeUrl}library/${contextKey}`; |
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.
Not everyone has the library authoring MFE enabled.. and I don't think it'll be ready for Redwood either.. Is there some MFE way of detecting this and getting the right base URL to use?
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.
Yes!
I made a refactor here: 6cb2d96
If we don't have the redirect URL the hit will be shown as disabled.
src/search-modal/SearchResult.jsx
Outdated
} | ||
return `/course/${contextKey}?show=${encodeURIComponent(usageKey)}`; | ||
} | ||
if (usageKey.includes('lb:')) { |
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.
nit -- since you used startsWith
above:
if (usageKey.includes('lb:')) { | |
if (usageKey.startsWith('lb:')) { |
Someday soon we're going to want MFE libraries for opaque keys.. but that's out of scope here :)
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.
Done: 53d70e3
} | ||
|
||
navigate(url); | ||
closeSearch?.(); |
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.
Is that how our other modals work? If so, then yes, I agree that's worth doing here too.
src/search-modal/SearchResult.jsx
Outdated
gap={2} | ||
> | ||
<div className="align-top"> | ||
<Icon className="align-top" src={ItemIcon[hit.block_type] || Article} /> |
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.
The icons in Figma look to be a lighter grey, and maybe a bit more padding between the icon and the text?
Figma:
MFE:
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.
Done: f1b3b62
src/search-modal/SearchResult.jsx
Outdated
<Snippet attribute="content.capa_content" hit={hit} highlightedTagName="b" /> | ||
</div> | ||
<div className="text-muted x-small"> | ||
<CustomHighlight attribute="breadcrumbsNames" separator=" / " hit={hit} /> |
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.
The figma designs omit the Course Title from the breadcrumbs when searching just "This course".
The Course Title should only be shown if we're searching "All courses".
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.
Done: c152a42
|
||
div.row:has(> div > div.highlight) { | ||
animation: 5s glow; | ||
} | ||
|
||
@keyframes glow { | ||
0% { | ||
box-shadow: 0 0 5px 5px $primary-500; | ||
} | ||
|
||
90% { | ||
box-shadow: 0 0 5px 5px $primary-500; | ||
} | ||
|
||
100% { | ||
box-shadow: unset; | ||
} | ||
} |
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.
@rpenido I agree that the scrolling is awkward.. but I can't think of a better place to send someone who's searched for a Section/Subsection.
However, if they search for a Unit, I think we should direct them to the Unit edit page instead of scrolling down the outline, because Units are very unlikely to be expanded on that page. So then it's just Sections and Subsections that use the scrolling thing, and Units and components redirect to the Unit edit page.
@ali-hugo What do you think?
Co-authored-by: Jillian <[email protected]>
b71b0b5
to
53d70e3
Compare
f98778b
to
6cb2d96
Compare
@rpenido I noticed a couple warnings in the console:
|
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.
Thanks for addressing my comments @rpenido 👍
I've left a comment about missing tests, but I'm ok with them being covered by your follow-up task.
- I tested this on my tutor dev stack using the PR test instructions
- I read through the code
- I checked for accessibility issues by navigating with my keyboard.
- Includes documentation
- User-facing strings are extracted for translation
@@ -59,7 +64,7 @@ describe('<SearchModal />', () => { | |||
apiKey: 'test-api-key', | |||
}); | |||
const { findByText } = render(<RootWrapper />); | |||
expect(await findByText('Enter a keyword or select a filter to begin searching.')).toBeInTheDocument(); | |||
expect(await findByText('Start searching to find content')).toBeInTheDocument(); |
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.
Can you add more tests to cover the added functionality for this SearchModal?
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.
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.
I think this is good to go on my side. Just very few small issues that I think would be nice if addressed.
src/search-modal/SearchModal.scss
Outdated
.fs-large { | ||
font-size: $font-size-base * 1.25; | ||
} |
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.
You can use the class lead
instead of using this. ref
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.
Nice! Thank you!
Done: 78e0a81
src/search-modal/EmptyStates.jsx
Outdated
const EmptySearch = () => ( | ||
<Stack className="d-flex mt-6 align-items-center"> | ||
<p className="fs-large"> <FormattedMessage {...messages.emptySearchTitle} /> </p> | ||
<p className="small text-muted"> <FormattedMessage {...messages.emptySearchSubtitle} /> </p> | ||
<img src={EmptySearchImage} alt="" /> | ||
</Stack> | ||
); | ||
|
||
const NoResults = () => ( | ||
<Stack className="d-flex mt-6 align-items-center"> | ||
<p className="fs-large"> <FormattedMessage {...messages.noResultsTitle} /> </p> | ||
<p className="small text-muted"> <FormattedMessage {...messages.noResultsSubtitle} /> </p> | ||
<img src={NoResultImage} alt="" /> | ||
</Stack> | ||
); | ||
|
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.
I think these should be deduplicated since they have the same structure, and will likely need to always have the same structure.
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.
Done: 78e0a81
|
||
div.row:has(> div > div.highlight) { | ||
animation: 5s glow; | ||
} | ||
|
||
@keyframes glow { | ||
0% { | ||
box-shadow: 0 0 5px 5px $primary-500; | ||
} | ||
|
||
90% { | ||
box-shadow: 0 0 5px 5px $primary-500; | ||
} | ||
|
||
100% { | ||
box-shadow: unset; | ||
} | ||
} |
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.
What seems to be the issue with the animation? I think one thing that can be done to make it smoother is to use a timing function.
i.e. remove the 90% step and add a timing function like:
animation-timing-function: cubic-bezier(1,0,.72,.04);
This will be a lot smoother I think since it'll follow a curve rather than a steep fall.
838c55e
to
4860614
Compare
Thank you for catching that @bradenmacdonald! |
4860614
to
8e468ef
Compare
12ba0c5
to
079e52e
Compare
Co-authored-by: Braden MacDonald <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #946 +/- ##
==========================================
+ Coverage 92.06% 92.09% +0.02%
==========================================
Files 634 634
Lines 11029 11080 +51
Branches 2367 2387 +20
==========================================
+ Hits 10154 10204 +50
- Misses 846 847 +1
Partials 29 29 ☔ View full report in Codecov by Sentry. |
3e52a20
to
879a395
Compare
17e4012
to
66612bc
Compare
8cd53fe
to
7d037f2
Compare
@rpenido 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
Description
This PR improves the
SearchResult
component, which shows the hits for the search feature.More Infomation
Testing Instructions
Setup
meilisearch
setup locally, follow the setup instructions here https://github.com/open-craft/tutor-contrib-meilisearchcontentstore.new_studio_mfe.use_new_course_outline_page
waffle flag is enabled.Testing
NOTE If the content is visible on the page (not collapsed), the page will be scrolled and the content will be highlighted for 5 seconds. This will NOT happen if the content is inside a collapsed parent.
Private ref: FAL-3695