signal-desktop/ts/components/StopPropagation.tsx

26 lines
615 B
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ReactNode } from 'react';
import React from 'react';
// Whenever you don't want click or key events to propagate into their parent container
2022-11-18 00:45:19 +00:00
export function StopPropagation({
children,
className,
}: {
children: ReactNode;
className?: string;
2022-11-18 00:45:19 +00:00
}): JSX.Element {
return (
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div
className={className}
onClick={ev => ev.stopPropagation()}
onKeyDown={ev => ev.stopPropagation()}
>
{children}
</div>
);
}