Skip to content

Commit f1cb434

Browse files
Merge pull request #27 from code4rena-dev/develop
Bug fix - stopping event propagation
2 parents e17ed7e + eef3aae commit f1cb434

File tree

3 files changed

+53
-35
lines changed

3 files changed

+53
-35
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@code4rena/components-library",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "Code4rena's official components library ",
55
"types": "./dist/lib.d.ts",
66
"exports": {

src/lib/ContestTile/CompactTemplate.tsx

+14-2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const IsContest = ({title, contestData, sponsorUrl, sponsorImage}: {
103103
target="_blank"
104104
rel="noreferrer noopener"
105105
className="logo"
106+
onClick={(e) => e.stopPropagation()}
106107
>
107108
<img
108109
alt="Sponsor logo"
@@ -122,7 +123,12 @@ const IsContest = ({title, contestData, sponsorUrl, sponsorImage}: {
122123
)}
123124
<div className="content">
124125
<h2 className="title">
125-
<a href={`${contestUrl}#top`}>{title}</a>
126+
<a
127+
href={contestUrl}
128+
onClick={(e) => e.stopPropagation()}
129+
>
130+
{title}
131+
</a>
126132
</h2>
127133
</div>
128134
<p className="amount">{amount}</p>
@@ -147,6 +153,7 @@ const IsBounty = ({title, bountyData, sponsorUrl, sponsorImage}: {
147153
target="_blank"
148154
rel="noreferrer noopener"
149155
className="logo"
156+
onClick={(e) => e.stopPropagation()}
150157
>
151158
<img
152159
alt="Sponsor logo"
@@ -165,7 +172,12 @@ const IsBounty = ({title, bountyData, sponsorUrl, sponsorImage}: {
165172
/>
166173
)}
167174
<h2 className="title">
168-
<a href={bountyUrl ? `${bountyUrl}#top` : '#'}>{title}</a>
175+
<a
176+
href={bountyUrl}
177+
onClick={(e) => e.stopPropagation()}
178+
>
179+
{title}
180+
</a>
169181
</h2>
170182
<p className="type">Bug Bounty</p>
171183
</header>

src/lib/ContestTile/DefaultTemplate.tsx

+38-32
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export default function DefaultTemplate({
153153
sponsorUrl={sponsorUrl}
154154
sponsorImage={sponsorImage}
155155
bountyData={bountyData}
156-
dropdownLinks={dropdownLinks}
157156
bountyTimelineObject={bountyTimelineObject}
158157
updateBountyTileStatus={updateBountyTileStatus}
159158
/>}
@@ -240,7 +239,7 @@ function IsContest({
240239
updateContestTileStatus: () => void;
241240
contestTimelineObject: ContestSchedule | undefined;
242241
}) {
243-
const { contestUrl, amount, findingsRepo } = contestData;
242+
const { contestUrl, amount, findingsRepo, startDate, endDate } = contestData;
244243

245244
return (
246245
<Fragment>
@@ -253,13 +252,14 @@ function IsContest({
253252
target="_blank"
254253
rel="noreferrer noopener"
255254
className="logo"
255+
onClick={(e) => e.stopPropagation()}
256256
>
257-
<img
258-
alt="Sponsor logo"
259-
src={sponsorImage ?? "/"}
260-
width={88}
261-
height={88}
262-
/>
257+
<img
258+
alt="Sponsor logo"
259+
src={sponsorImage ?? "/"}
260+
width={88}
261+
height={88}
262+
/>
263263
</a>
264264
) : (
265265
<img
@@ -281,7 +281,12 @@ function IsContest({
281281
</small>
282282
{/* Contest title */}
283283
<h2 className="title">
284-
<a href={contestUrl ? `${contestData.contestUrl}#top` : '#'}>{title}</a>
284+
<a
285+
href={contestUrl}
286+
onClick={(e) => e.stopPropagation()}
287+
>
288+
{title}
289+
</a>
285290
</h2>
286291
{/* Contest description */}
287292
<p className="description">
@@ -313,30 +318,31 @@ function IsContest({
313318
<div className="details">
314319
{contestTimelineObject && <ContestStatus
315320
className={`status ${clsx(
316-
contestTimelineObject.contestStatus === Status.ENDED && "ended"
321+
contestTimelineObject.contestStatus === Status.ENDED && "ended"
317322
)}`}
318323
status={contestTimelineObject.contestStatus}
319324
/>}
320-
{contestTimelineObject && contestTimelineObject.contestStatus !== Status.ENDED && (
325+
{contestData && contestTimelineObject && contestTimelineObject.contestStatus !== Status.ENDED && (
321326
<div className="timer">
322-
<Countdown
323-
start={contestData.startDate}
324-
end={contestData.endDate}
325-
updateContestStatus={updateContestTileStatus}
326-
text={
327-
contestTimelineObject.contestStatus === Status.UPCOMING
328-
? "Starts in "
329-
: "Ends in "
330-
}
331-
/>
327+
<Countdown
328+
start={startDate}
329+
end={endDate}
330+
updateContestStatus={updateContestTileStatus}
331+
text={
332+
contestTimelineObject.contestStatus === Status.UPCOMING
333+
? "Starts in "
334+
: "Ends in "
335+
}
336+
/>
332337
</div>
333338
)}
334339
</div>
335340
<div className="options">
336341
<a
337342
className="contest-redirect"
338343
aria-label="View audit"
339-
href={`${contestData.contestUrl}`}
344+
href={contestUrl}
345+
onClick={(e) => e.stopPropagation()}
340346
>
341347
{!findingsRepo || findingsRepo === "" ? "Preview" : "View"} audit
342348
</a>
@@ -353,7 +359,6 @@ function IsBounty({
353359
sponsorUrl,
354360
sponsorImage,
355361
bountyData,
356-
dropdownLinks,
357362
updateBountyTileStatus,
358363
bountyTimelineObject
359364
}: {
@@ -362,12 +367,6 @@ function IsBounty({
362367
sponsorUrl?: string;
363368
sponsorImage?: string;
364369
bountyData: BountyTileData;
365-
dropdownLinks: {
366-
label: string;
367-
href: string;
368-
external?: boolean;
369-
ariaLabel?: string;
370-
}[]
371370
updateBountyTileStatus?: () => void;
372371
bountyTimelineObject?: ContestSchedule | undefined;
373372
}) {
@@ -385,6 +384,7 @@ function IsBounty({
385384
target="_blank"
386385
rel="noreferrer noopener"
387386
className="logo"
387+
onClick={(e) => e.stopPropagation()}
388388
>
389389
<img
390390
alt="Sponsor logo"
@@ -405,7 +405,12 @@ function IsBounty({
405405
<div className="content--wrapper">
406406
{/* Contest title */}
407407
<h2 className="title">
408-
<a href={bountyUrl ? `${bountyUrl}#top` : '#'}>{title}</a>
408+
<a
409+
href={bountyUrl}
410+
onClick={(e) => e.stopPropagation()}
411+
>
412+
{title}
413+
</a>
409414
</h2>
410415
{/* Contest description */}
411416
<p className="description">
@@ -428,7 +433,7 @@ function IsBounty({
428433
)}`}
429434
status={bountyTimelineObject.contestStatus}
430435
/>}
431-
{bountyTimelineObject && bountyTimelineObject.contestStatus === Status.UPCOMING && (
436+
{bountyData && bountyTimelineObject && bountyTimelineObject.contestStatus === Status.UPCOMING && (
432437
<div className="timer">
433438
<Countdown
434439
start={startDate}
@@ -443,7 +448,8 @@ function IsBounty({
443448
<a
444449
className="contest-redirect"
445450
aria-label="View bounty"
446-
href={`${bountyUrl}`}
451+
href={bountyUrl}
452+
onClick={(e) => e.stopPropagation()}
447453
>
448454
View details
449455
</a>

0 commit comments

Comments
 (0)