Skip to content

Commit

Permalink
user able to open pages (#8)
Browse files Browse the repository at this point in the history
* user able to open pages

* added spaced

---------

Co-authored-by: vr-varad <varadgupta21#gmail.com>
  • Loading branch information
vr-varad authored Aug 20, 2024
1 parent 4ce9bde commit 375595c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions web/src/components/WikipediaBrowser/WikipediaBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,19 @@ const WikipediaBrowser: React.FC = () => {
const handleLinkClick = useCallback((e: React.MouseEvent<HTMLDivElement>, paneIndex: number) => {
const target = e.target as HTMLElement;
const link = target.closest("a");
if (link instanceof HTMLAnchorElement && link.href && link.title) {
const image = target.closest("img")
if ( image ) {
e.preventDefault();
setClickedLinks(prev => new Set(prev).add(link.href));
setActivePane(paneIndex);
fetchWikipediaContent(link.title);
e.stopPropagation();
window.open(image.src, "_blank");
} else {
if (link instanceof HTMLAnchorElement && link.href && link.title) {
e.preventDefault();
e.stopPropagation()
setClickedLinks(prev => new Set(prev).add(link.href));
setActivePane(paneIndex);
fetchWikipediaContent(link.title);
}
}
}, [fetchWikipediaContent]);

Expand Down

0 comments on commit 375595c

Please sign in to comment.