Skip to content

Commit 3bec717

Browse files
committed
style: same style for editing username that manager's
1 parent 7232232 commit 3bec717

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/components/modals/UserDataModal.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ const UserDataModal: React.FC<UserDataModalProps> = ({ onOpenChange }) => {
113113
setData({ type: 'SET_USERNAME', payload: usernameInput });
114114
setIsEditingUsername(false);
115115
};
116+
117+
// Handle keyboard events for input fields
118+
const handleKeyDown = (e: React.KeyboardEvent, saveFunction: () => void) => {
119+
if (e.key === 'Enter') {
120+
e.preventDefault();
121+
saveFunction();
122+
}
123+
};
116124

117125
// Handler for clicks outside the modal
118126
const handleOutsideClick = (e: React.MouseEvent<HTMLDivElement>) => {
@@ -182,14 +190,15 @@ const UserDataModal: React.FC<UserDataModalProps> = ({ onOpenChange }) => {
182190
<div>
183191
<label
184192
htmlFor='username'
185-
className='block text-sm font-medium text-gray-700 mb-1'
193+
className='block text-xs font-medium text-gray-500 mb-0.5'
186194
>
187195
Your Name
188196
</label>
189-
<Input
197+
<input
190198
id='username'
191199
value={usernameInput}
192200
onChange={(e) => setUsernameInput(e.target.value)}
201+
onKeyDown={(e) => handleKeyDown(e, handleSaveUsername)}
193202
placeholder='Enter your name'
194203
aria-label='Your Name'
195204
className='w-full h-8 rounded-md border border-pink-200 focus:border-brand-pink text-gray-500 text-sm px-2'
@@ -329,6 +338,7 @@ const UserDataModal: React.FC<UserDataModalProps> = ({ onOpenChange }) => {
329338
id='managerName'
330339
value={managerNameInput}
331340
onChange={(e) => setManagerNameInput(e.target.value)}
341+
onKeyDown={(e) => handleKeyDown(e, handleSaveContact)}
332342
placeholder="Manager's name"
333343
aria-label='Manager Name'
334344
className='w-full h-8 rounded-md border border-pink-200 focus:border-brand-pink text-gray-500 text-sm px-2'
@@ -345,6 +355,7 @@ const UserDataModal: React.FC<UserDataModalProps> = ({ onOpenChange }) => {
345355
id='managerEmail'
346356
value={managerEmailInput}
347357
onChange={(e) => setManagerEmailInput(e.target.value)}
358+
onKeyDown={(e) => handleKeyDown(e, handleSaveContact)}
348359
placeholder="Manager's email"
349360
aria-label='Manager Email'
350361
className='w-full h-8 rounded-md border border-pink-200 focus:border-brand-pink text-gray-500 text-sm px-2'

0 commit comments

Comments
 (0)