Skip to content

Commit

Permalink
chore: disable shortcut customization ui
Browse files Browse the repository at this point in the history
  • Loading branch information
emcelroy committed Nov 26, 2024
1 parent 5f609e7 commit ea9c8f1
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/components/keyboard-shortcut-controls.tsx
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
import React, { FormEvent, useState } from "react";
import React from "react";

import "./keyboard-shortcut-controls.scss";

interface IProps {
shortcutEnabled: boolean;
shortcutKeys: string;
shortcutKeys?: string;
onCustomizeShortcut?: (shortcut: string) => void;
onToggleShortcut: () => void;
}

export const KeyboardShortcutControls = (props: IProps) => {
const { shortcutEnabled, shortcutKeys, onCustomizeShortcut, onToggleShortcut } = props;
const { shortcutEnabled, onToggleShortcut } = props;
const toggleButtonLabel = shortcutEnabled ? "Disable Shortcut" : "Enable Shortcut";
const [showError, setShowError] = useState(false);
const [showConfirmation, setShowConfirmation] = useState(false);
// const [showError, setShowError] = useState(false);
// const [showConfirmation, setShowConfirmation] = useState(false);

const handleToggleShortcut = () => {
onToggleShortcut();
};

const handleCustomizeShortcut = (event: FormEvent) => {
event.preventDefault();
const form = event.target as HTMLInputElement;
const shortcut = form.querySelector("input")?.value;
if (shortcut) {
onCustomizeShortcut?.(shortcut);
setShowError(false);
setShowConfirmation(true);
} else {
setShowError(true);
setShowConfirmation(false);
}
};
// const handleCustomizeShortcut = (event: FormEvent) => {
// event.preventDefault();
// const form = event.target as HTMLInputElement;
// const shortcut = form.querySelector("input")?.value;
// if (shortcut) {
// onCustomizeShortcut?.(shortcut);
// setShowError(false);
// setShowConfirmation(true);
// } else {
// setShowError(true);
// setShowConfirmation(false);
// }
// };

const customShortcutInputDescribedBy = showConfirmation
? "custom-keyboard-shortcut-confirmation"
: showError
? "custom-keyboard-shortcut-error"
: undefined;
// const customShortcutInputDescribedBy = showConfirmation
// ? "custom-keyboard-shortcut-confirmation"
// : showError
// ? "custom-keyboard-shortcut-error"
// : undefined;

return (
<div className="keyboard-shortcut-controls">
<h3>Keyboard Shortcut</h3>
<button onClick={handleToggleShortcut} data-testid="keyboard-shortcut-toggle">
{toggleButtonLabel}
</button>
<form data-testid="custom-keyboard-shortcut-form" onSubmit={handleCustomizeShortcut}>
{/* <form data-testid="custom-keyboard-shortcut-form" onSubmit={handleCustomizeShortcut}>
<fieldset disabled={!shortcutEnabled}>
<label htmlFor="custom-keyboard-shortcut">Customize Keystroke</label>
<input
Expand Down Expand Up @@ -87,7 +87,7 @@ export const KeyboardShortcutControls = (props: IProps) => {
</div>
}
</fieldset>
</form>
</form> */}
</div>
);
};

0 comments on commit ea9c8f1

Please sign in to comment.