fix: enable context menu in editable element

This commit is contained in:
GyDi 2023-07-22 17:21:04 +08:00
parent 031a253101
commit 3748e420a0

View File

@ -87,7 +87,17 @@ const Layout = () => {
}}
onContextMenu={(e) => {
// only prevent it on Windows
if (OS === "windows") e.preventDefault();
const validList = ["input", "textarea"];
const target = e.currentTarget;
if (
OS === "windows" &&
!(
validList.includes(target.tagName.toLowerCase()) ||
target.isContentEditable
)
) {
e.preventDefault();
}
}}
sx={[
({ palette }) => ({