diff --git a/packages/volto/news/6481.bugfix b/packages/volto/news/6481.bugfix new file mode 100644 index 0000000000..996c4d61f7 --- /dev/null +++ b/packages/volto/news/6481.bugfix @@ -0,0 +1 @@ +While editing a block, and in the sidebar under the {guilabel}`Settings` tab, when an item has {guilabel}`Required` checked, then it can no longer be deleted under the {guilabel}`Order` tab. Similarly, when {guilabel}`Fixed position` is checked, the item's ordered position can no longer be changed. Previously neither option was honored. @alihamza1221 \ No newline at end of file diff --git a/packages/volto/src/components/manage/Blocks/Block/BlocksForm.jsx b/packages/volto/src/components/manage/Blocks/Block/BlocksForm.jsx index a8fd1e7c05..93aba076fd 100644 --- a/packages/volto/src/components/manage/Blocks/Block/BlocksForm.jsx +++ b/packages/volto/src/components/manage/Blocks/Block/BlocksForm.jsx @@ -283,6 +283,7 @@ const BlocksForm = (props) => { onMoveBlock={onMoveBlockEnhanced} onDeleteBlock={onDeleteBlock} onSelectBlock={onSelectBlock} + editable={editable} removable errors={blocksErrors} /> diff --git a/packages/volto/src/components/manage/Blocks/Block/EditBlockWrapper.jsx b/packages/volto/src/components/manage/Blocks/Block/EditBlockWrapper.jsx index 3ef354708b..0effa9aca8 100644 --- a/packages/volto/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +++ b/packages/volto/src/components/manage/Blocks/Block/EditBlockWrapper.jsx @@ -17,6 +17,7 @@ import { defineMessages, injectIntl } from 'react-intl'; import cx from 'classnames'; import config from '@plone/volto/registry'; import BlockChooserButton from '@plone/volto/components/manage/BlockChooser/BlockChooserButton'; +import { hideHandler } from '@plone/volto/helpers/Blocks/Blocks'; import trashSVG from '@plone/volto/icons/delete.svg'; @@ -28,14 +29,6 @@ const messages = defineMessages({ }); const EditBlockWrapper = (props) => { - const hideHandler = (data) => { - return ( - !!data.fixed || - (!config.experimental.addBlockButton.enabled && - !(blockHasValue(data) && props.blockProps.editable)) - ); - }; - const { intl, blockProps, draginfo, children } = props; const { allowedBlocks, @@ -59,7 +52,7 @@ const EditBlockWrapper = (props) => { const data = applyBlockDefaults({ data: originalData, ...blockProps, intl }); - const visible = selected && !hideHandler(data); + const visible = selected && !hideHandler(data, editable); const required = isBoolean(data.required) ? data.required diff --git a/packages/volto/src/components/manage/Blocks/Block/Order/Item.jsx b/packages/volto/src/components/manage/Blocks/Block/Order/Item.jsx index f09233ee62..0a7563c2c8 100644 --- a/packages/volto/src/components/manage/Blocks/Block/Order/Item.jsx +++ b/packages/volto/src/components/manage/Blocks/Block/Order/Item.jsx @@ -2,10 +2,12 @@ import React, { forwardRef } from 'react'; import classNames from 'classnames'; import { useDispatch, useSelector } from 'react-redux'; import includes from 'lodash/includes'; +import isBoolean from 'lodash/isBoolean'; import cx from 'classnames'; import Icon from '@plone/volto/components/theme/Icon/Icon'; import { setUIState } from '@plone/volto/actions/form/form'; import config from '@plone/volto/registry'; +import { hideHandler } from '@plone/volto/helpers/Blocks/Blocks'; import deleteSVG from '@plone/volto/icons/delete.svg'; import dragSVG from '@plone/volto/icons/drag.svg'; @@ -39,6 +41,12 @@ export const Item = forwardRef( const gridSelected = useSelector((state) => state.form.ui.gridSelected); const dispatch = useDispatch(); + const visible = !hideHandler(data, props?.editable); + + const required = isBoolean(data?.required) + ? data?.required + : includes(config.blocks.requiredBlocks, data?.['@type']); + return (
  • @@ -112,7 +124,7 @@ export const Item = forwardRef( {data?.plaintext || config.blocks.blocksConfig[data?.['@type']]?.title} - {!clone && onRemove && ( + {!clone && onRemove && !required && (