Skip to content

Commit

Permalink
FIX Enable bypassing entwine onsubmit handler
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Feb 26, 2024
1 parent cfd8e5e commit 2db1365
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion client/dist/js/bundle.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions client/src/components/FormBuilder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ the submission process works as follows:

See [handleSubmit](http://redux-form.com/6.0.5/docs/api/Props.md#-handlesubmit-eventorsubmit-function-)
in the redux-form docs for more details.

Note that submissions from a `<FormBuilder>` component that rendered inside part of a regular edit form may
have their submission event intercepted by entwine by `onsubmit` in `LeftAndMain.EditForm.js`. You
can add a `bypass-entwine` class to your react component to prevent this behaviour.
5 changes: 5 additions & 0 deletions client/src/legacy/LeftAndMain.EditForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@ $.entwine('ss', function($){
* Suppress submission unless it is handled through ajaxSubmit().
*/
onsubmit: function(e, button) {
// If the submit button a child of on an element with a .bypass-entwine class on it then
// skip handling. Usually the element in question will be used by react e.g. FormBuilder
if ($(e.target.activeElement).closest('.bypass-entwine').length) {
return true;
}
// Only submit if a button is present.
// This supressed submits from ENTER keys in input fields,
// which means the browser auto-selects the first available form button.
Expand Down

0 comments on commit 2db1365

Please sign in to comment.