← All changes
|
assets/js/packages/editor-controls/editor-controls.js
+10
-3
4.3.0-beta2
→
4.3.3
View file →
| @@ -9418,9 +9418,9 @@ | ||
| 9418 | 9418 | }; |
| 9419 | 9419 | |
| 9420 | 9420 | //#endregion |
| 9421 | 9421 | //#region packages/packages/libs/editor-controls/src/controls/toggle-control.tsx |
| 9422 | - var ToggleControl = createControl(({ options, fullWidth = false, size = "tiny", exclusive = true, maxItems, convertOptions = false }) => { | |
| 9422 | + var ToggleControl = createControl(({ options, fullWidth = false, size = "tiny", exclusive = true, maxItems, convertOptions = false, allowEmpty = false }) => { | |
| 9423 | 9423 | const { value, setValue, placeholder, disabled } = useBoundProp(_elementor_editor_props.stringPropTypeUtil); |
| 9424 | 9424 | const processedOptions = convertOptions ? convertToggleOptionsToAtomic(options) : options; |
| 9425 | 9425 | const exclusiveValues = processedOptions.filter((option) => option.exclusive).map((option) => option.value); |
| 9426 | 9426 | const handleNonExclusiveToggle = (selectedValues) => { |
| @@ -9434,12 +9434,19 @@ | ||
| 9434 | 9434 | fullWidth, |
| 9435 | 9435 | size, |
| 9436 | 9436 | placeholder |
| 9437 | 9437 | }; |
| 9438 | + const handleExclusiveToggle = (selectedValue) => { | |
| 9439 | + if (allowEmpty && !selectedValue) { | |
| 9440 | + setValue(""); | |
| 9441 | + return; | |
| 9442 | + } | |
| 9443 | + setValue(selectedValue); | |
| 9444 | + }; | |
| 9438 | 9445 | return exclusive ? /* @__PURE__ */ react.createElement(ControlToggleButtonGroup, { |
| 9439 | 9446 | ...toggleButtonGroupProps, |
| 9440 | - value: value ?? null, | |
| 9441 | - onChange: setValue, | |
| 9447 | + value: allowEmpty ? value || null : value ?? null, | |
| 9448 | + onChange: handleExclusiveToggle, | |
| 9442 | 9449 | disabled, |
| 9443 | 9450 | exclusive: true |
| 9444 | 9451 | }) : /* @__PURE__ */ react.createElement(ControlToggleButtonGroup, { |
| 9445 | 9452 | ...toggleButtonGroupProps, |