-
Notifications
You must be signed in to change notification settings - Fork 42
Prevent interaction with a field that hasnt loaded yet #3533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1900,6 +1900,11 @@ window.frmAdminBuildJS = function() { | |
| } | ||
|
|
||
| function updateFieldGroupControls( $row, count ) { | ||
| const row = $row.get( 0 ); | ||
| if ( ! row || row.querySelector( ':scope > .frm_field_loading' ) ) { | ||
| return; | ||
| } | ||
|
|
||
| const rowOffset = $row.offset(); | ||
|
|
||
| if ( rowOffset === undefined ) { | ||
|
|
@@ -2939,11 +2944,32 @@ window.frmAdminBuildJS = function() { | |
| */ | ||
| function prepareInteractedFieldSettings( event ) { | ||
| const field = event.target.closest( '#frm-show-fields li.form-field' ); | ||
| if ( field ) { | ||
| if ( field && ! field.classList.contains( 'frm_field_loading' ) ) { | ||
| ensureFieldSettings( field.dataset.fid ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Stop placeholder mouse events before delegated selection and hover handlers run. | ||
| * | ||
| * @since x.x | ||
| * @param {MouseEvent} event The interaction inside the builder fields container. | ||
| * @return {void} | ||
| */ | ||
| function ignoreLoadingFieldMouseEvent( event ) { | ||
| if ( ! event.target.closest( '.frm_field_loading' ) ) { | ||
| return; | ||
| } | ||
|
|
||
| // Clear the previous row before stopping the delegated hover cleanup. | ||
| if ( false !== maybeRemoveGroupHoverTarget() ) { | ||
| deleteTooltips(); | ||
| } | ||
|
|
||
| event.preventDefault(); | ||
| event.stopImmediatePropagation(); | ||
| } | ||
|
|
||
| /** | ||
| * Initialize only the fields inserted in this slice before yielding to user input. | ||
| * | ||
|
|
@@ -3394,6 +3420,11 @@ window.frmAdminBuildJS = function() { | |
| const list = elementFromPoint.closest( 'ul.frm_sorting' ); | ||
|
|
||
| if ( null !== list && ! list.classList.contains( 'start_divider' ) && 'frm-show-fields' !== list.id ) { | ||
| if ( list.querySelector( ':scope > .frm_field_loading' ) ) { | ||
| maybeRemoveGroupHoverTarget(); | ||
| return; | ||
| } | ||
|
|
||
| const previousHoverTarget = maybeRemoveGroupHoverTarget(); | ||
| if ( false !== previousHoverTarget && ! jQuery( previousHoverTarget ).is( list ) ) { | ||
| destroyFieldGroupPopup(); | ||
|
|
@@ -11920,6 +11951,10 @@ window.frmAdminBuildJS = function() { | |
|
|
||
| buildInit() { | ||
| hydrateFieldPlaceholders(); | ||
| const fieldsContainer = document.getElementById( 'frm-show-fields' ); | ||
| [ 'click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', 'mouseover', 'mouseout', 'contextmenu' ].forEach( eventType => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Observed live: hover a loaded field (Field 10), then move onto the placeholder below. Cosmetic only. If you want it gone, call |
||
| fieldsContainer.addEventListener( eventType, ignoreLoadingFieldMouseEvent, true ); | ||
| } ); | ||
| document.addEventListener( 'click', prepareInteractedFieldSettings, true ); | ||
| document.addEventListener( 'focusin', prepareInteractedFieldSettings, true ); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: Strategy11/formidable-forms
Length of output: 45681
🏁 Script executed:
Repository: Strategy11/formidable-forms
Length of output: 42076
🌐 Web query:
official jQuery UI mouse widget source _mouseMoveDelegate _mouseUpDelegate _mouseStop document mouseup💡 Result:
Allow drag events over loading placeholders.
When a loaded field is dragged, jQuery UI uses document-level
mousemoveandmouseuphandlers. The capture handler stops those events inside.frm_field_loading, sohandleDragStop()may not run and the drag UI can remain active.Keep blocking other placeholder interactions, but remove only
mouseupandmousemove:Suggested fix
🤖 Prompt for AI Agents