Skip to content

Conversation

martinjagodic
Copy link
Member

Fixes #4702

  • adds allow_remove and allow_reorder flags to the list widgets
  • if either is set to false, UI does not render the drag handle/remove button
  • they are added to schemas

@martinjagodic martinjagodic requested a review from a team as a code owner August 11, 2025 07:59
@martinjagodic martinjagodic requested review from demshy and Copilot and removed request for a team August 11, 2025 09:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds new configuration flags allow_remove and allow_reorder to list widgets, allowing users to control whether list items can be removed or reordered. The changes implement conditional rendering of UI controls based on these flags.

  • Added allow_remove and allow_reorder boolean properties to list widget schemas
  • Modified UI components to conditionally render drag handles and remove buttons based on these flags
  • Updated TypeScript definitions and test snapshots to reflect the new properties

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/decap-cms-widget-list/src/schema.js Adds allow_remove and allow_reorder boolean properties to the widget schema
packages/decap-cms-widget-list/src/ListControl.js Passes the new flags from field configuration to the UI component
packages/decap-cms-ui-default/src/ListItemTopBar.js Implements conditional rendering logic for drag handles and remove buttons
packages/decap-cms-core/src/types/redux.ts Adds TypeScript type definitions for the new properties
packages/decap-cms-widget-list/src/tests/snapshots/ListControl.spec.js.snap Updates test snapshots to include the new props

Comment on lines +66 to +72
{dragHandle && allowReorder ? <DragHandle Wrapper={dragHandle} id={id} /> : <span></span>}
{onRemove && allowRemove ? (
<TopBarButton onClick={onRemove}>
<Icon type="close" size="small" />
</TopBarButton>
) : null}
) : (
<span></span>
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using empty <span></span> elements as placeholders creates unnecessary DOM nodes. Consider using null instead for cleaner rendering when elements are not needed.

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spans are used to keep the number of elements in the top row, to keep the item spacing consistent.

<TopBarButton onClick={onRemove}>
<Icon type="close" size="small" />
</TopBarButton>
) : null}
) : (
<span></span>
Copy link
Preview

Copilot AI Aug 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using empty <span></span> elements as placeholders creates unnecessary DOM nodes. Consider using null instead for cleaner rendering when elements are not needed.

Suggested change
<span></span>
null

Copilot uses AI. Check for mistakes.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spans are used to keep the number of elements in the top row, to keep the item spacing consistent.

kyoshino added a commit to sveltia/sveltia-cms that referenced this pull request Aug 11, 2025
@martinjagodic martinjagodic merged commit ff961f4 into decaporg:main Aug 12, 2025
7 checks passed
@martinjagodic martinjagodic deleted the allow-remove_reorder branch August 12, 2025 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add allow_delete property in list widget
2 participants