Skip to content

Commit

Permalink
Merge pull request #2333 from OneCommunityGlobal/Nathalia_make_blue_s…
Browse files Browse the repository at this point in the history
…quare_description_box_bigger_and_auto-fit

Nathalia make blue square description box bigger and auto-fit
  • Loading branch information
one-community authored Jun 8, 2024
2 parents f92f18e + ff33fa4 commit d482eb5
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/components/UserProfile/UserProfileModal/UserProfileModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ const UserProfileModal = props => {
} else if (event.target.id === 'summary') {
setSummary(event.target.value);
checkFields(dateStamp, summary);
adjustTextareaHeight(event.target);
} else if (event.target.id === 'date') {
setDateStamp(event.target.value);
setSummaryFieldView(false);
Expand All @@ -142,6 +143,11 @@ const UserProfileModal = props => {
}
}

const adjustTextareaHeight = (textarea) => {
textarea.style.height = 'auto';
textarea.style.height = `${textarea.scrollHeight}px`;
};

const boxStyling = darkMode ? boxStyleDark : boxStyle;
const fontColor = darkMode ? 'text-light' : '';

Expand Down Expand Up @@ -315,7 +321,14 @@ const UserProfileModal = props => {

<FormGroup hidden={summaryFieldView}>
<Label className={fontColor} for="report">Summary</Label>
<Input type="textarea" id="summary" onChange={handleChange} />
<Input
type="textarea"
id="summary"
onChange={handleChange}
value={summary}
style={{ minHeight: '200px', overflow: 'hidden'}}
onInput={e => adjustTextareaHeight(e.target)}
/>
</FormGroup>
</>
)}
Expand All @@ -334,7 +347,14 @@ const UserProfileModal = props => {
</FormGroup>
<FormGroup>
<Label className={fontColor} for="report">Summary</Label>
<Input type="textarea" onChange={e => setSummary(e.target.value)} value={summary} />
<Input
type="textarea"
id="summary"
onChange={handleChange}
value={summary}
style={{ minHeight: '200px', overflow: 'hidden'}} // 4x taller than usual
onInput={e => adjustTextareaHeight(e.target)} // auto-adjust height
/>
</FormGroup>
</>
)}
Expand Down

0 comments on commit d482eb5

Please sign in to comment.