2022-06-03 21:07:51 +00:00
|
|
|
// Copyright 2021-2022 Signal Messenger, LLC
|
2021-10-04 20:56:34 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ReactNode } from 'react';
|
|
|
|
import React from 'react';
|
2021-10-04 20:56:34 +00:00
|
|
|
|
2021-11-01 15:46:36 +00:00
|
|
|
// Whenever you don't want click or key events to propagate into their parent container
|
2021-10-04 20:56:34 +00:00
|
|
|
export const StopPropagation = ({
|
|
|
|
children,
|
2021-10-05 13:58:34 +00:00
|
|
|
className,
|
2021-10-04 20:56:34 +00:00
|
|
|
}: {
|
|
|
|
children: ReactNode;
|
2021-10-05 13:58:34 +00:00
|
|
|
className?: string;
|
2021-10-04 20:56:34 +00:00
|
|
|
}): JSX.Element => (
|
2022-06-03 21:07:51 +00:00
|
|
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
2021-11-01 15:46:36 +00:00
|
|
|
<div
|
|
|
|
className={className}
|
|
|
|
onClick={ev => ev.stopPropagation()}
|
|
|
|
onKeyDown={ev => ev.stopPropagation()}
|
|
|
|
>
|
2021-10-05 13:58:34 +00:00
|
|
|
{children}
|
|
|
|
</div>
|
2021-10-04 20:56:34 +00:00
|
|
|
);
|