Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keyboard shortcut for adding notes #6915

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Components/Facility/ConsultationDoctorNotes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { PatientNoteStateType } from "../models.js";
import routes from "../../../Redux/api.js";
import request from "../../../Utils/request/request.js";
import useQuery from "../../../Utils/request/useQuery.js";
import useKeyboardShortcut from "use-keyboard-shortcut";
import { isAppleDevice } from "../../../Utils/utils.js";

interface ConsultationDoctorNotesProps {
patientId: string;
Expand All @@ -26,6 +28,7 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
const [reload, setReload] = useState(false);
const [facilityName, setFacilityName] = useState("");
const [patientName, setPatientName] = useState("");
const [focused, setFocused] = useState(false);

const initialData: PatientNoteStateType = {
notes: [],
Expand Down Expand Up @@ -84,6 +87,18 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
}
});

useKeyboardShortcut(
[isAppleDevice ? "Meta" : "Shift", "Enter"],
() => {
if (focused) {
onAddNote();
}
},
{
ignoreInputFields: false,
}
);

return (
<Page
title="Doctor Notes"
Expand Down Expand Up @@ -114,6 +129,8 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
errorClassName="hidden"
placeholder="Type your Note"
disabled={!patientActive}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
<ButtonV2
onClick={onAddNote}
Expand Down
18 changes: 17 additions & 1 deletion src/Components/Facility/PatientNotesSlideover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useEffect, Dispatch, SetStateAction } from "react";
import * as Notification from "../../Utils/Notifications.js";
import { NonReadOnlyUsers } from "../../Utils/AuthorizeFor";
import CareIcon from "../../CAREUI/icons/CareIcon";
import { classNames } from "../../Utils/utils";
import { classNames, isAppleDevice } from "../../Utils/utils";
import TextFormField from "../Form/FormFields/TextFormField";
import ButtonV2 from "../Common/components/ButtonV2";
import { make as Link } from "../Common/components/Link.bs";
Expand All @@ -11,6 +11,7 @@ import PatientConsultationNotesList from "./PatientConsultationNotesList";
import request from "../../Utils/request/request";
import routes from "../../Redux/api";
import { PatientNoteStateType } from "./models";
import useKeyboardShortcut from "use-keyboard-shortcut";

interface PatientNotesProps {
patientId: string;
Expand All @@ -24,6 +25,7 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
const [patientActive, setPatientActive] = useState(true);
const [noteField, setNoteField] = useState("");
const [reload, setReload] = useState(false);
const [focused, setFocused] = useState(false);

const initialData: PatientNoteStateType = {
notes: [],
Expand Down Expand Up @@ -84,6 +86,18 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
fetchPatientName();
}, [patientId]);

useKeyboardShortcut(
[isAppleDevice ? "Meta" : "Shift", "Enter"],
() => {
if (focused) {
onAddNote();
}
},
{
ignoreInputFields: false,
}
);

const notesActionIcons = (
<div className="flex gap-1">
{show && (
Expand Down Expand Up @@ -157,6 +171,8 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
errorClassName="hidden"
placeholder="Type your Note"
disabled={!patientActive}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
<ButtonV2
id="add_doctor_note_button"
Expand Down
Loading