-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow click on searched file's path
In the search, we display the folder path for files results. It is not possible to click on it, to directly open the folder rather than the file itself.
- Loading branch information
1 parent
7135435
commit 13f29a9
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Code copied and adapted from cozy-drive | ||
* | ||
* See source: https://github.com/cozy/cozy-drive/blob/fbe2df67199683b23a40f476ccdacb00ee027459/src/modules/search/components/SuggestionItemTextSecondary.jsx | ||
*/ | ||
import React from 'react' | ||
|
||
import AppLinker from 'cozy-ui/transpiled/react/AppLinker' | ||
import SuggestionItemTextHighlighted from './SuggestionItemTextHighlighted' | ||
import useBreakpoints from 'cozy-ui/transpiled/react/providers/Breakpoints' | ||
|
||
import styles from './styles.styl' | ||
|
||
const SuggestionItemTextSecondary = ({ text, query, url, slug }) => { | ||
const { isMobile } = useBreakpoints() | ||
|
||
if (isMobile || !url) { | ||
return <SuggestionItemTextHighlighted text={text} query={query} /> | ||
} | ||
|
||
const app = { slug } | ||
return ( | ||
<AppLinker app={app} href={url}> | ||
{({ href, onClick }) => ( | ||
<a | ||
className={styles['suggestion-item-parent-link']} | ||
href={href} | ||
onClick={e => { | ||
e.stopPropagation() | ||
if (typeof onClick == 'function') { | ||
onClick(e) | ||
} | ||
}} | ||
> | ||
<SuggestionItemTextHighlighted | ||
text={text} | ||
query={query} | ||
slug={slug} | ||
/> | ||
</a> | ||
)} | ||
</AppLinker> | ||
) | ||
} | ||
|
||
export default SuggestionItemTextSecondary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters