From 7ee95956968409fbf6effcaac5ae7fa36903f1fa Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Thu, 5 Jun 2025 17:48:46 -0500 Subject: [PATCH 1/2] fix: Rename icon size & make the button disappear while editing --- .../InplaceTextEditor.test.tsx | 21 ++++++++++++++++++ src/generic/inplace-text-editor/index.tsx | 22 ++++++++++--------- .../LibraryAuthoringPage.tsx | 2 +- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/generic/inplace-text-editor/InplaceTextEditor.test.tsx b/src/generic/inplace-text-editor/InplaceTextEditor.test.tsx index c4dbc46191..0aca1e50b9 100644 --- a/src/generic/inplace-text-editor/InplaceTextEditor.test.tsx +++ b/src/generic/inplace-text-editor/InplaceTextEditor.test.tsx @@ -110,4 +110,25 @@ describe('', () => { // Show original text expect(screen.getByText('Test text')).toBeInTheDocument(); }); + + it('should dissapear edit button while editing', async () => { + render(); + + const title = screen.getByText('Test text'); + expect(title).toBeInTheDocument(); + + const editButton = screen.getByRole('button', { name: /edit/i }); + expect(editButton).toBeInTheDocument(); + fireEvent.click(editButton); + + const textBox = screen.getByRole('textbox'); + expect(editButton).not.toBeInTheDocument(); + + fireEvent.change(textBox, { target: { value: 'New text' } }); + fireEvent.keyDown(textBox, { key: 'Enter', code: 'Enter', charCode: 13 }); + + expect(textBox).not.toBeInTheDocument(); + expect(mockOnSave).toHaveBeenCalledWith('New text'); + expect(await screen.findByRole('button', { name: /edit/i })).toBeInTheDocument(); + }); }); diff --git a/src/generic/inplace-text-editor/index.tsx b/src/generic/inplace-text-editor/index.tsx index 89c97a2a04..cb07d2ffa9 100644 --- a/src/generic/inplace-text-editor/index.tsx +++ b/src/generic/inplace-text-editor/index.tsx @@ -92,17 +92,19 @@ export const InplaceTextEditor: React.FC = ({ /> ) : ( - - {text} - + <> + + {text} + + + )} - ); }; diff --git a/src/library-authoring/LibraryAuthoringPage.tsx b/src/library-authoring/LibraryAuthoringPage.tsx index 5a739643da..e3ffa6c288 100644 --- a/src/library-authoring/LibraryAuthoringPage.tsx +++ b/src/library-authoring/LibraryAuthoringPage.tsx @@ -114,7 +114,7 @@ export const SubHeaderTitle = ({ title }: { title: ReactNode }) => { const showReadOnlyBadge = readOnly && !componentPickerMode; return ( - + {title} {showReadOnlyBadge && (
From de9d1eb9a3207e64caf3a94b5c5ec6b6bf30aef3 Mon Sep 17 00:00:00 2001 From: XnpioChV Date: Thu, 5 Jun 2025 18:51:28 -0500 Subject: [PATCH 2/2] style: Use the correct type in useUpdateContainer --- src/generic/inplace-text-editor/InplaceTextEditor.test.tsx | 2 +- src/library-authoring/LibraryAuthoringPage.tsx | 2 +- src/library-authoring/data/apiHooks.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/generic/inplace-text-editor/InplaceTextEditor.test.tsx b/src/generic/inplace-text-editor/InplaceTextEditor.test.tsx index 0aca1e50b9..9b7a55c281 100644 --- a/src/generic/inplace-text-editor/InplaceTextEditor.test.tsx +++ b/src/generic/inplace-text-editor/InplaceTextEditor.test.tsx @@ -111,7 +111,7 @@ describe('', () => { expect(screen.getByText('Test text')).toBeInTheDocument(); }); - it('should dissapear edit button while editing', async () => { + it('should disappear edit button while editing', async () => { render(); const title = screen.getByText('Test text'); diff --git a/src/library-authoring/LibraryAuthoringPage.tsx b/src/library-authoring/LibraryAuthoringPage.tsx index e3ffa6c288..d2db117acd 100644 --- a/src/library-authoring/LibraryAuthoringPage.tsx +++ b/src/library-authoring/LibraryAuthoringPage.tsx @@ -114,7 +114,7 @@ export const SubHeaderTitle = ({ title }: { title: ReactNode }) => { const showReadOnlyBadge = readOnly && !componentPickerMode; return ( - + {title} {showReadOnlyBadge && (
diff --git a/src/library-authoring/data/apiHooks.ts b/src/library-authoring/data/apiHooks.ts index 8573804ffc..3098e37560 100644 --- a/src/library-authoring/data/apiHooks.ts +++ b/src/library-authoring/data/apiHooks.ts @@ -619,7 +619,7 @@ export const useUpdateContainer = (containerId: string) => { return useMutation({ mutationFn: (data: api.UpdateContainerDataRequest) => api.updateContainerMetadata(containerId, data), onMutate: (data) => { - const previousData = queryClient.getQueryData(containerQueryKey) as api.CollectionMetadata; + const previousData = queryClient.getQueryData(containerQueryKey) as api.Container; queryClient.setQueryData(containerQueryKey, { ...previousData, ...data,