Skip to content

Commit

Permalink
fixes #7495
Browse files Browse the repository at this point in the history
  • Loading branch information
rithviknishad committed May 6, 2024
1 parent 57cd550 commit ba2aaf4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 36 deletions.
3 changes: 2 additions & 1 deletion src/Components/Facility/ConsultationDoctorNotes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ const ConsultationDoctorNotes = (props: ConsultationDoctorNotesProps) => {
name="note"
value={noteField}
onChange={(e) => setNoteField(e.value)}
className="grow"
className="w-full grow"
innerClassName="pr-10"
errorClassName="hidden"
placeholder="Type your Note"
disabled={!patientActive}
Expand Down
57 changes: 27 additions & 30 deletions src/Components/Facility/PatientNotesSlideover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,36 +208,33 @@ export default function PatientNotesSlideover(props: PatientNotesProps) {
disableEdit={!patientActive}
/>
<div className="relative mx-4 flex items-center">
<div className=" w-full px-12">
<AutoExpandingTextInputFormField
id="doctor_notes_textarea"
maxHeight={160}
rows={1}
name="note"
value={noteField}
onChange={(e) => setNoteField(e.value)}
className="grow"
errorClassName="hidden"
placeholder="Type your Note"
disabled={!patientActive}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
</div>
<div className="flex items-center">
<ButtonV2
id="add_doctor_note_button"
onClick={onAddNote}
border={false}
className="absolute right-2"
ghost
size="small"
disabled={!patientActive}
authorizeFor={NonReadOnlyUsers}
>
<CareIcon icon="l-message" className="text-lg" />
</ButtonV2>
</div>
<AutoExpandingTextInputFormField
id="doctor_notes_textarea"
maxHeight={160}
rows={1}
name="note"
value={noteField}
onChange={(e) => setNoteField(e.value)}
className="w-full grow"
errorClassName="hidden"
innerClassName="pr-10"
placeholder="Type your Note"
disabled={!patientActive}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
/>
<ButtonV2
id="add_doctor_note_button"
onClick={onAddNote}
border={false}
className="absolute right-2"
ghost
size="small"
disabled={!patientActive}
authorizeFor={NonReadOnlyUsers}
>
<CareIcon icon="l-message" className="text-lg" />
</ButtonV2>
</div>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useRef } from "react";
import { useEffect, useRef } from "react";
import TextAreaFormField, { TextAreaFormFieldProps } from "./TextAreaFormField";

type AutoExpandingTextInputFormFieldProps = TextAreaFormFieldProps & {
Expand All @@ -9,6 +9,7 @@ const AutoExpandingTextInputFormField = (
props: AutoExpandingTextInputFormFieldProps,
) => {
const myref = useRef<HTMLTextAreaElement>(null);

useEffect(() => {
if (myref.current == null) return;
const text = myref.current.textContent?.split("\n");
Expand All @@ -24,7 +25,7 @@ const AutoExpandingTextInputFormField = (
myref.current.style.cssText = "height:" + height + "px";
});

return <TextAreaFormField ref={myref} {...props} className="w-full" />;
return <TextAreaFormField ref={myref} {...props} />;
};

export default AutoExpandingTextInputFormField;
10 changes: 7 additions & 3 deletions src/Components/Form/FormFields/TextAreaFormField.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import { forwardRef } from "react";
import FormField from "./FormField";
import { FormFieldBaseProps, useFormFieldPropsResolver } from "./Utils";
import { classNames } from "../../../Utils/utils";

export type TextAreaFormFieldProps = FormFieldBaseProps<string> & {
placeholder?: string;
value?: string | number;
rows?: number;
// prefixIcon?: React.ReactNode;
// suffixIcon?: React.ReactNode;
innerClassName?: string;
onFocus?: (event: React.FocusEvent<HTMLTextAreaElement>) => void;
onBlur?: (event: React.FocusEvent<HTMLTextAreaElement>) => void;
};
Expand All @@ -30,9 +32,11 @@ const TextAreaFormField = forwardRef(
onChange={(e) => field.handleChange(e.target.value)}
placeholder={props.placeholder}
rows={rows}
className={`cui-input-base resize-none ${
field.error && "border-danger-500"
}`}
className={classNames(
"cui-input-base resize-none",
field.error && "border-danger-500",
props.innerClassName,
)}
onFocus={props.onFocus}
onBlur={props.onBlur}
/>
Expand Down

0 comments on commit ba2aaf4

Please sign in to comment.