kevinchappell / formBuilder

A jQuery plugin for drag and drop form creation
https://formbuilder.online
MIT License
2.62k stars 1.39k forks source link

When Double-click trumbowyg area will open the Edit issue #1584

Closed ShingZtore closed 2 months ago

ShingZtore commented 3 months ago

Description:

When I set fields : [{ label: "html", id: "htmlTextArea", type: "trumbowyg", }] And disabledFieldButtons: { trumbowyg: ['edit'] // disables the edit button for select fields },

Environment Details:

Expected Behavior

Double click anywhere should not open the Edit.

Actual Behavior

Double-click trumbowyg plugin auto open the Edit.

Steps to Reproduce

Screenshot - (optional)

image image

lucasnetau commented 3 months ago

Disabling the edit button doesn't disable the edit panel opening on double click. The current dblClick event handler only targets contenteditable and a few element types to allow you to double click within the content editable box.

If you want to block all editing then look at hooking into the onAddFieldAfter event and set a dblClick handler on the .trumbowyg class to prevent propagating the event (currently $stage.on('dblclick', 'li.form-field') is where the event bubbles up to in order to open the edit field) or remove that event handler

ShingZtore commented 3 months ago

Thank you!

I share my solution:

onAddFieldAfter: function(fieldId, fieldData) {
    // Your code that handles reacting to the added field
    $('li.trumbowyg-field').on('dblclick', function(event) {
        event.stopPropagation();
    });
},
lucasnetau commented 2 months ago

Thank you. Closing.