From 43b4668fa80c3c6789f6b6f7fb151d7871d902a4 Mon Sep 17 00:00:00 2001 From: stefano bovio Date: Mon, 29 May 2023 12:11:26 +0200 Subject: [PATCH] Fix #9197 Disable apply media editor button while loading a selected item (#9198) (#9199) --- .../selectors/__tests__/mediaEditor-test.js | 15 ++++++++++++++- web/client/selectors/mediaEditor.js | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/web/client/selectors/__tests__/mediaEditor-test.js b/web/client/selectors/__tests__/mediaEditor-test.js index 4fce11b3c9..7d30815f96 100644 --- a/web/client/selectors/__tests__/mediaEditor-test.js +++ b/web/client/selectors/__tests__/mediaEditor-test.js @@ -27,7 +27,8 @@ import { getCurrentMediaResourcesParams, getCurrentMediaResourcesTotalCount, getLoadingSelectedMedia, - getLoadingMediaList + getLoadingMediaList, + disableApplyMapMedia } from "../mediaEditor"; describe('mediaEditor selectors', () => { @@ -278,4 +279,16 @@ describe('mediaEditor selectors', () => { } })).toBe(true); }); + it('disableApplyMapMedia', () => { + expect(disableApplyMapMedia({ + mediaEditor: { + loadingSelected: true + } + })).toBe(true); + expect(disableApplyMapMedia({ + mediaEditor: { + loadingSelected: false + } + })).toBe(false); + }); }); diff --git a/web/client/selectors/mediaEditor.js b/web/client/selectors/mediaEditor.js index b1b2ca59f8..d6eacaf072 100644 --- a/web/client/selectors/mediaEditor.js +++ b/web/client/selectors/mediaEditor.js @@ -62,6 +62,8 @@ export const disabledMediaTypeSelector = state => get(state, "mediaEditor.disabl /** * Disable `apply` on empty selection for map media editor when geostory section is GeoCarousel, * here disable media type value is available only in GeoCarousel section + * The apply button should be disabled also when a selected item is loading */ export const disableApplyMapMedia = (state) => - disabledMediaTypeSelector(state).length && !selectedItemSelector(state) && currentMediaTypeSelector(state) === 'map'; + (disabledMediaTypeSelector(state).length && !selectedItemSelector(state) && currentMediaTypeSelector(state) === 'map') + || getLoadingSelectedMedia(state);