Skip to content

Commit

Permalink
fix: recurrence widget bug when closing and opening multiple times wi…
Browse files Browse the repository at this point in the history
…thout saving (#741)

* fix: initial fixes, still broken, cannot save anymore

* fix: completed fixes of RecurrentWidget?

* chore: new test deploy action

* fix: recurrence start date calculations

* chore: RELEASE.md wrong merge strategy by git

* chore: remove test deploy action
  • Loading branch information
deodorhunter authored and pnicolli committed Oct 3, 2024
1 parent b483949 commit 0ad425c
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 130 deletions.
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
### Fix

- Risolto un problema con il blocco Form che in alcuni casi poteva dare problemi di validazione dei campi di tipo 'testo statico'.
- Sistemate diverse incogruenze e errori generati dal widget per la creazione delle ricorrenze nel CT Evento.

## Versione 11.23.2 (24/09/2024)

Expand Down
5 changes: 2 additions & 3 deletions src/customizations/volto/components/manage/Diff/DiffField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ const DiffField = ({
const second = SSRRenderHtml(history, store, two, field);
parts = diff2(first, second);
} else if (schema.type === 'array') {
// debugger;
const oneArray = (one || []).map((i) => i?.title || i).join(', ');
const twoArray = (two || []).map((j) => j?.title || j).join(', ');
parts = diff2(oneArray, twoArray);
Expand Down Expand Up @@ -150,8 +149,8 @@ const DiffField = ({
schema?.type === 'boolean'
? booleanMapping[!!one]
: schema?.widget === 'json'
? contentOne
: one,
? contentOne
: one,
schema?.widget ??
(schema?.type === 'object' && field.includes('image')
? field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* - added customization to have this changes https://github.com/plone/volto/pull/5555/files
*/

import React from 'react';
import React, { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl } from 'react-intl';
import { Form, Grid, Input, Radio } from 'semantic-ui-react';
Expand All @@ -25,6 +25,12 @@ const messages = defineMessages({
* @returns {string} Markup of the component.
*/
const EndField = ({ value, count, until, onChange, intl }) => {
// Give state to fields, updating logic is convoluted,
// update only when/if needed
const [occurrenceValue, setOccurrenceValue] = useState(count);
const [untilValue, setUntilValue] = useState(until);
useEffect(() => setOccurrenceValue(count), [count]);
useEffect(() => setUntilValue(until), [until]);
return (
<Form.Field inline className="text">
<Grid>
Expand Down Expand Up @@ -55,12 +61,12 @@ const EndField = ({ value, count, until, onChange, intl }) => {
<Input
id="count"
name="count"
value={count || ''}
value={occurrenceValue || ''}
onChange={({ target }) => {
onChange(
target.id,
target.value === '' ? undefined : target.value,
);
setOccurrenceValue(target.value);
if (target.value) {
onChange(target.id, parseInt(target.value));
}
}}
/>
</Form.Field>
Expand All @@ -86,15 +92,16 @@ const EndField = ({ value, count, until, onChange, intl }) => {
title={intl.formatMessage(messages.recurrenceEndsUntil)}
dateOnly={true}
value={
until
? typeof until === 'string'
? until
: until?.toISOString()
untilValue
? typeof untilValue === 'string'
? untilValue
: untilValue?.toISOString()
: ''
}
resettable={false}
onChange={(id, value) => {
onChange(id, value === '' ? undefined : value);
setUntilValue(value);
if (value) onChange(id, value === '' ? undefined : value);
}}
/>
</Form.Field>
Expand Down
Loading

0 comments on commit 0ad425c

Please sign in to comment.