Fixes for feedback form

This commit is contained in:
Jordan Eldredge 2021-11-12 19:55:12 -08:00
parent ee2ca7bef5
commit f81cebe298
3 changed files with 11 additions and 2 deletions

View file

@ -16,6 +16,10 @@ export default function Feedback() {
const url = useSelector(getUrl);
const send = useCallback(async () => {
const body = { message, email, url: "https://skins/webamp.org" + url };
if (message.trim().length === 0) {
alert("Please add a message before sending.");
return;
}
setSending(true);
await fetch(`${API_URL}/feedback`, {
method: "POST",

View file

@ -27,9 +27,10 @@ function SearchLogo() {
function useFocusOnSlash() {
const [input, setInput] = useState(null);
const feedbackFormOpen = useSelector(Selectors.getFeedbackFormOpen);
useEffect(() => {
if (input == null) {
if (input == null || feedbackFormOpen) {
return;
}
const handler = (e) => {
@ -45,7 +46,7 @@ function useFocusOnSlash() {
return () => {
window.document.removeEventListener("keydown", handler);
};
}, [input]);
}, [input, feedbackFormOpen]);
return setInput;
}

View file

@ -246,3 +246,7 @@ export function getUploadedFiles(state) {
});
return files;
}
export function getFeedbackFormOpen(state) {
return state.showFeedbackForm;
}