Skip to content

Commit 0ae89b9

Browse files
Merge pull request #385 from microsoft/psl-bug-16837
fix: DocGen- Save action triggers error when no changes are made to template title
2 parents adbba54 + f1232cc commit 0ae89b9

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

src/frontend/src/components/ChatHistory/ChatHistoryListItem.tsx

+20-6
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,14 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
225225
tabIndex={0}
226226
aria-label="chat history item"
227227
className={styles.itemCell}
228-
onClick={() => handleSelectItem()}
229-
onKeyDown={e => (e.key === 'Enter' || e.key === ' ' ? handleSelectItem() : null)}
228+
onClick={() => {if (!edit) handleSelectItem()}}
229+
onKeyDown={e => {
230+
if (!edit && (e.key === 'Enter' || e.key === ' ')) {
231+
handleSelectItem();
232+
} else {
233+
e.stopPropagation(); // stop from reaching here when editing
234+
}
235+
}}
230236
verticalAlign="center"
231237
// horizontal
232238
onMouseEnter={() => setIsHovered(true)}
@@ -258,7 +264,7 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
258264
<Stack aria-label="action button group" horizontal verticalAlign={'center'}>
259265
<IconButton
260266
role="button"
261-
disabled={errorRename !== undefined}
267+
disabled={errorRename !== undefined || editTitle == item.title}
262268
onKeyDown={e => (e.key === ' ' || e.key === 'Enter' ? handleSaveEdit(e) : null)}
263269
onClick={e => handleSaveEdit(e)}
264270
aria-label="confirm new title"
@@ -311,13 +317,21 @@ export const ChatHistoryListItemCell: React.FC<ChatHistoryListItemCellProps> = (
311317
disabled={isButtonDisabled}
312318
onKeyDown={e => (e.key === ' ' ? toggleDeleteDialog() : null)}
313319
/>
314-
<IconButton
320+
<IconButton
315321
className={styles.itemButton}
316322
iconProps={{ iconName: 'Edit' }}
317323
title="Edit"
318-
onClick={onEdit}
324+
onClick={(e) => {
325+
e.stopPropagation(); // Prevent triggering parent click
326+
onEdit();
327+
}}
319328
disabled={isButtonDisabled}
320-
onKeyDown={e => (e.key === ' ' ? onEdit() : null)}
329+
onKeyDown={(e) => {
330+
if (e.key === ' ') {
331+
e.stopPropagation(); // Prevent triggering parent keydown
332+
onEdit();
333+
}
334+
}}
321335
/>
322336
</Stack>
323337
)}

src/frontend/src/components/ChatHistory/chatHistoryListItem.test.tsx

-11
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,6 @@ describe('ChatHistoryListItemCell', () => {
487487
// Simulate clicking the confirm button
488488
userEvent.click(screen.getByRole('button', { name: 'confirm new title' }))
489489

490-
// Wait for the error message to appear
491-
await waitFor(() => {
492-
expect(screen.getByText(/Error: Enter a new title to proceed./i)).toBeInTheDocument()
493-
})
494490

495491
// Wait for the error message to disappear after 5 seconds
496492
await waitFor(() => expect(screen.queryByText('Error: Enter a new title to proceed.')).not.toBeInTheDocument(), {
@@ -550,18 +546,11 @@ describe('ChatHistoryListItemCell', () => {
550546
await userEvent.type(inputItem, 'update Chat')
551547
})
552548

553-
userEvent.click(screen.getByRole('button', { name: 'confirm new title' }))
554-
555-
await waitFor(() => {
556-
expect(screen.getByText(/Error: Enter a new title to proceed./i)).toBeInTheDocument()
557-
})
558549

559550
// Wait for the error to be hidden after 5 seconds
560551
await waitFor(() => expect(screen.queryByText('Error: could not rename item')).not.toBeInTheDocument(), {
561552
timeout: 6000
562553
})
563-
const input = screen.getByLabelText('chat history item')
564-
expect(input).toHaveFocus()
565554
}, 10000)
566555

567556
test('shows error when trying to rename to an existing title', async () => {

0 commit comments

Comments
 (0)