MCPcopy Create free account
hub / github.com/dailydotdev/apps / onClick

Function onClick

packages/shared/src/components/shell/ReadingDrawer.tsx:264–292  ·  view source on GitHub ↗
(event: MouseEvent)

Source from the content-addressed store, hash-verified

262 [post.permalink, getReadArticleHref(post)].filter(Boolean),
263 );
264 const onClick = (event: MouseEvent) => {
265 const anchor = (event.target as Element | null)?.closest?.('a[href]');
266 if (!(anchor instanceof HTMLAnchorElement)) {
267 return;
268 }
269 const isArticle = hrefs.has(anchor.href);
270 if (
271 !isArticle &&
272 !(
273 isOutsideLink(anchor) &&
274 !isShareLink(anchor) &&
275 anchor.closest('main') &&
276 !anchor.closest('[data-feed-item]')
277 )
278 ) {
279 return;
280 }
281 event.preventDefault();
282 if (!isReadingOpen()) {
283 enter(anchor.href, isArticle ? OpenOrigin.Post : OpenOrigin.Link);
284 return;
285 }
286 // From the pulled-up post, Read sinks it back over the page; another
287 // link loads in the page behind.
288 if (!isArticle) {
289 postReading(ReadingAction.Open, { url: anchor.href, postId: post.id });
290 }
291 sink.current?.();
292 };
293 document.addEventListener('click', onClick, true);
294 return () => document.removeEventListener('click', onClick, true);
295 }, [isAvailable, post, enter]);

Callers 1

SquadsToShareFunction · 0.50

Calls 5

isOutsideLinkFunction · 0.90
isShareLinkFunction · 0.90
isReadingOpenFunction · 0.90
postReadingFunction · 0.90
glideToFunction · 0.70

Tested by

no test coverage detected