Fix pro issue 5978 / fix issue with moving a field group after draggi…#2485
Conversation
…ng a field that exists into a group that previously had a single element
WalkthroughAdds an internal helper to make a field group draggable after a field is dropped into it and calls that helper from the existing handleFieldDrop flow in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant UI as Admin UI (Drag & Drop)
participant H as handleFieldDrop
participant M as maybeMakeFieldGroupDraggableAfterDragging
participant D as makeDraggable
U->>UI: Drop field into field group
UI->>H: handleFieldDrop(placeholder, field)
H->>H: Move existing field to target
H->>M: maybeMakeFieldGroupDraggableAfterDragging(placeholder.parentElement)
alt Parent is a field-group UL, not a start_divider, not main list, and li not draggable
M->>D: makeDraggable(fieldGroupLi, ".frm-move")
else Parent not a field group or already draggable
M-->>H: No action
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
js/src/admin/admin.js (1)
1018-1031: Harden helper with null checks and tighter selectorGuard against null/other node types, and scope closest() to the group LI to avoid accidental matches. Readability: prefer tagName over nodeName.
-function maybeMakeFieldGroupDraggableAfterDragging( placeholderParent ) { - const isDroppingIntoFieldGroup = placeholderParent.nodeName === 'UL' - && ! placeholderParent.classList.contains( 'start_divider' ) - && 'frm-show-fields' !== placeholderParent.id; - - if ( ! isDroppingIntoFieldGroup ) { - return; - } - - const fieldGroupLi = placeholderParent.closest( 'li' ); - if ( fieldGroupLi && ! fieldGroupLi.classList.contains( 'ui-draggable' ) ) { - makeDraggable( fieldGroupLi, '.frm-move' ); - } -} +function maybeMakeFieldGroupDraggableAfterDragging( placeholderParent ) { + if ( ! placeholderParent || placeholderParent.tagName !== 'UL' ) { + return; + } + const isFieldGroupUl = ! placeholderParent.classList.contains( 'start_divider' ) + && placeholderParent.id !== 'frm-show-fields'; + if ( ! isFieldGroupUl ) { + return; + } + const fieldGroupLi = placeholderParent.closest( 'li.frm_field_box' ); + if ( fieldGroupLi && ! fieldGroupLi.classList.contains( 'ui-draggable' ) ) { + makeDraggable( fieldGroupLi, '.frm-move' ); + } +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
js/src/admin/admin.js(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: Run PHP Syntax inspection (8.3)
- GitHub Check: Cypress
- GitHub Check: PHP 7.4 tests in WP trunk
- GitHub Check: PHP 8 tests in WP trunk
- GitHub Check: Cypress
🔇 Additional comments (1)
js/src/admin/admin.js (1)
994-999: Good fix: enables group dragging after moving an existing field into a previously single-field groupCalling the helper right after moving the field addresses the reported issue without affecting other paths.
|
Thanks Sherv! |
…ng a field that exists into a group that previously had a single element
Fixes https://github.com/Strategy11/formidable-pro/issues/5978