diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index d9e290cfff8..dc6cdfacb31 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -757,6 +757,7 @@ playwright.storybook.config.ts @grafana/grafana-frontend-platform
# public folder
/public/app/api/ @grafana/grafana-frontend-platform
+/public/app/api/clients/folder/ @grafana/grafana-search-navigate-organise
/public/app/core/actions/ @grafana/grafana-frontend-platform
/public/app/core/app_events.ts @grafana/grafana-frontend-platform
/public/app/core/components/AccessControl/ @grafana/identity-access-team
diff --git a/public/app/api/clients/folder/v1beta1/hooks.test.ts b/public/app/api/clients/folder/v1beta1/hooks.test.ts
index 0b8aa0eceed..715f7ef12ae 100644
--- a/public/app/api/clients/folder/v1beta1/hooks.test.ts
+++ b/public/app/api/clients/folder/v1beta1/hooks.test.ts
@@ -260,12 +260,22 @@ describe.each([
});
describe('useCreateFolder', () => {
- it('creates a folder', async () => {
+ it('creates a folder at the root level', async () => {
const { user } = setupCreateFolder();
- await user.click(screen.getByText('Create Folder'));
+ await user.click(screen.getByText(/Create Folder at root/));
expect(await screen.findByText('Folder created')).toBeInTheDocument();
+ expect(dispatchMockFn).toHaveBeenCalled();
+ });
+
+ it('creates a folder in a nested folder', async () => {
+ const { user } = setupCreateFolder();
+
+ await user.click(screen.getByText(/Create Folder in nested folder/));
+
+ expect(await screen.findByText('Folder created')).toBeInTheDocument();
+ expect(dispatchMockFn).toHaveBeenCalled();
});
});
diff --git a/public/app/api/clients/folder/v1beta1/hooks.ts b/public/app/api/clients/folder/v1beta1/hooks.ts
index e9b3214daa0..fca72781955 100644
--- a/public/app/api/clients/folder/v1beta1/hooks.ts
+++ b/public/app/api/clients/folder/v1beta1/hooks.ts
@@ -379,7 +379,8 @@ function useRefreshFolders() {
if (options.parentsOf) {
dispatch(refreshParents(options.parentsOf));
}
- if (options.childrenOf) {
+ // Refetch children even if we passed in `childrenOf: undefined`, as this corresponds to the root folder
+ if (options.childrenOf || 'childrenOf' in options) {
dispatch(
refetchChildren({
parentUID: options.childrenOf,
diff --git a/public/app/api/clients/folder/v1beta1/test-utils.tsx b/public/app/api/clients/folder/v1beta1/test-utils.tsx
index c120045fcf5..824c8131fc8 100644
--- a/public/app/api/clients/folder/v1beta1/test-utils.tsx
+++ b/public/app/api/clients/folder/v1beta1/test-utils.tsx
@@ -14,7 +14,10 @@ const TestCreationComponent = () => {
return (
<>