fix: enable context menu in editable element

This commit is contained in:
GyDi 2023-07-22 17:21:04 +08:00
parent 02ba04b5d8
commit 4c243638cb
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A

View File

@ -87,7 +87,17 @@ const Layout = () => {
}} }}
onContextMenu={(e) => { onContextMenu={(e) => {
// only prevent it on Windows // 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={[ sx={[
({ palette }) => ({ ({ palette }) => ({