Skip to content

Fix pro issue 5978 / fix issue with moving a field group after draggi…#2485

Merged
Crabcyborg merged 3 commits into
masterfrom
pro_issue_5978
Sep 5, 2025
Merged

Fix pro issue 5978 / fix issue with moving a field group after draggi…#2485
Crabcyborg merged 3 commits into
masterfrom
pro_issue_5978

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

…ng a field that exists into a group that previously had a single element

Fixes https://github.com/Strategy11/formidable-pro/issues/5978

…ng a field that exists into a group that previously had a single element
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 5, 2025

Walkthrough

Adds 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 js/src/admin/admin.js. No public/exported signatures changed.

Changes

Cohort / File(s) Summary of changes
Drag-and-drop post-drop handling
js/src/admin/admin.js
Added maybeMakeFieldGroupDraggableAfterDragging(placeholderParent) to detect drops into a field group and call makeDraggable(fieldGroupLi, '.frm-move') when appropriate. Invoked this helper in handleFieldDrop after moving an existing field. No exported signatures changed.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • shervElmi
  • AbdiTolesa

📜 Recent 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 91db009 and 6fe77f0.

📒 Files selected for processing (1)
  • js/src/admin/admin.js (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • js/src/admin/admin.js
⏰ 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)
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pro_issue_5978

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
js/src/admin/admin.js (1)

1018-1031: Harden helper with null checks and tighter selector

Guard 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.

📥 Commits

Reviewing files that changed from the base of the PR and between b7d922e and 91db009.

📒 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 group

Calling the helper right after moving the field addresses the reported issue without affecting other paths.

@Crabcyborg Crabcyborg requested a review from shervElmi September 5, 2025 12:16
Copy link
Copy Markdown
Contributor

@shervElmi shervElmi left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

Thanks Mike.

@Crabcyborg
Copy link
Copy Markdown
Contributor Author

Thanks Sherv!

@Crabcyborg Crabcyborg merged commit cd70af9 into master Sep 5, 2025
15 of 16 checks passed
@Crabcyborg Crabcyborg deleted the pro_issue_5978 branch September 5, 2025 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants