From d6ed83d92f67efbe1bd1c16440e22554b4416af5 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 Date: Sat, 22 Jul 2023 21:29:46 -0400 Subject: [PATCH] Add autofocus to remote fetch modal input --- .../components/common/subscribe-button.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/shared/components/common/subscribe-button.tsx b/src/shared/components/common/subscribe-button.tsx index 6e2a1561..1017c3a4 100644 --- a/src/shared/components/common/subscribe-button.tsx +++ b/src/shared/components/common/subscribe-button.tsx @@ -80,11 +80,27 @@ export function SubscribeButton({ ); } +function focusInput() { + document.getElementById("remoteFetchInstance")?.focus(); +} + class RemoteFetchModal extends Component { constructor(props, context) { super(props, context); } + componentDidMount() { + document + .getElementById("remoteFetchModal") + ?.addEventListener("shown.bs.modal", focusInput); + } + + componentWillUnmount(): void { + document + .getElementById("remoteFetchModal") + ?.removeEventListener("shown.bs.modal", focusInput); + } + render() { return (