diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks.js b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks.js index df4323043..c3fd932be 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks.js +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks.js @@ -114,6 +114,25 @@ export const updateDuration = ({ if (newValue > 86399000) { newValue = 86399000; } + + // stopTime must not be equal to 24:00:00, so when the user types 23:59:59 in the startTime field and stopTime field - + // set the startTime field to 23:59:58. + if (index === 'stopTime' && duration.startTime === 86399000) { + const startTime = 86399000 - 1000; + + setUnsavedDuration({ + startTime: module.durationStringFromValue(startTime), + stopTime: module.durationStringFromValue(newValue), + }); + setDuration({ + ...duration, + startTime, + stopTime: newValue, + }); + + return; + } + // stopTime must be at least 1 second, if not zero if (index === 'stopTime' && newValue > 0 && newValue < 1000) { newValue = 1000; diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks.test.js b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks.test.js index 8442005b1..dbdb2b7a9 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks.test.js +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/DurationWidget/hooks.test.js @@ -248,6 +248,26 @@ describe('Video Settings DurationWidget hooks', () => { }); }); }); + describe('if the passed stopTime = startTime', () => { + it('sets the startTime value less than stopTime value', () => { + testMethod({ + ...props, + duration: { startTime: 86399000, stopTime: 86399000 }, + unsavedDuration: { startTime: '23:59:59', stopTime: '23:59:59' }, + index: testStopIndex, + inputString: '23:59:59', + }); + expect(props.setUnsavedDuration).toHaveBeenCalledWith({ + startTime: '23:59:58', + stopTime: '23:59:59', + }); + expect(props.setDuration).toHaveBeenCalledWith({ + ...props.duration, + startTime: 86399000 - 1000, + stopTime: 86399000, + }); + }); + }); }); describe('onDurationChange', () => { beforeEach(() => {