-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SSP-2867] - disable link click on product list item text select text…
… (#3593)
- Loading branch information
1 parent
3a52c56
commit 06978de
Showing
6 changed files
with
111 additions
and
71 deletions.
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
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,17 @@ | ||
export const isTextSelected = () => { | ||
const selection = window.getSelection(); | ||
return selection && selection.toString().length > 0; | ||
}; | ||
|
||
export const disableClickWhenTextSelected = (e: React.MouseEvent<HTMLAnchorElement>) => { | ||
if (isTextSelected()) { | ||
preventClick(e); | ||
} | ||
return true; | ||
}; | ||
|
||
export const preventClick = (event: React.MouseEvent<HTMLAnchorElement>) => { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
return false; | ||
}; |