-
Notifications
You must be signed in to change notification settings - Fork 41
Add banner about updating default email address to email action #2239
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
base: master
Are you sure you want to change the base?
Changes from all commits
5a4b1a8
f0c0f69
1c88a33
22e4d5f
d5a82af
8426162
8b6d30f
76294fe
fa99e4a
3f667c8
fa88213
333a11c
479fd18
7c5367f
aebe6d4
ffce5eb
8257807
0d04ad1
3e282a2
0d9d969
613957b
5b8e852
d297f0a
2224ba3
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.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sendTestEmailModal: null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { doJsonPost } = frmDom.ajax; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function addEventListeners() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.addEventListener( 'change', handleChangeEvent ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.addEventListener( 'keydown', handleKeyDownEvent ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -29,6 +31,23 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function handleClickDismissDefaultEmailMessage( e ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( ! e.target.classList.contains( 'frm_dismiss_default_email_message' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.preventDefault(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const formData = new FormData(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| formData.append( 'action', 'frm_dismiss_default_email_message' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| formData.append( 'nonce', frmGlobal.nonce ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| doJsonPost( 'dismiss_default_email_message', formData ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .then( () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.closest( '.frm_default_email_message' ).remove(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .catch( error => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.error( error ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+34
to
+49
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. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Find where handleClickDismissDefaultEmailMessage is called from
rg -n 'handleClickDismissDefaultEmailMessage' --type=js -B 3 -A 3Repository: Strategy11/formidable-forms Length of output: 751 🏁 Script executed: #!/bin/bash
# Find doJsonPost implementation and usage patterns
rg -n 'doJsonPost\s*[:=]' --type=js -A 15Repository: Strategy11/formidable-forms Length of output: 927 🏁 Script executed: #!/bin/bash
# Also check all doJsonPost calls to understand the pattern
rg -n 'doJsonPost\s*\(' --type=js -B 2 -A 2Repository: Strategy11/formidable-forms Length of output: 6584 🏁 Script executed: #!/bin/bash
# Check how FormData with 'action' field is typically handled in WordPress
# Let's see if there are other patterns where action is appended to FormData
rg -n "formData\.append\(\s*['\"]action['\"]" --type=js -B 5 -A 5Repository: Strategy11/formidable-forms Length of output: 2570 🏁 Script executed: #!/bin/bash
# Read more context from settings.js around the test email handler for comparison
sed -n '100,130p' js/admin/settings.js | cat -nRepository: Strategy11/formidable-forms Length of output: 1256 🏁 Script executed: #!/bin/bash
# Look for ESLint config to understand the violations
fd -e '.eslintrc*' -e 'eslint.config*' --type=fRepository: Strategy11/formidable-forms Length of output: 53 🏁 Script executed: #!/bin/bash
# Check if there's a package.json with ESLint config
cat package.json 2>/dev/null | grep -A 20 '"eslint'Repository: Strategy11/formidable-forms Length of output: 53 Based on my verification, I can now provide the rewritten review comment with confirmed findings. Remove redundant class check, redundant FormData fields, and add defensive null check. This function duplicates checks and appends unnecessary FormData fields:
Apply this diff: function handleClickDismissDefaultEmailMessage( e ) {
- if ( ! e.target.classList.contains( 'frm_dismiss_default_email_message' ) ) {
- return;
- }
e.preventDefault();
+
const formData = new FormData();
- formData.append( 'action', 'frm_dismiss_default_email_message' );
- formData.append( 'nonce', frmGlobal.nonce );
+
doJsonPost( 'dismiss_default_email_message', formData )
- .then( () => {
- e.target.closest( '.frm_default_email_message' ).remove();
- })
- .catch( error => {
- console.error( error );
- });
+ .then( () => {
+ const notice = e.target.closest( '.frm_default_email_message' );
+ if ( notice ) {
+ notice.remove();
+ }
+ } )
+ .catch( error => {
+ console.error( error );
+ } );
}📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Check: Run ESLint[failure] 48-48: [failure] 48-48: [failure] 47-47: [failure] 46-46: [failure] 45-45: [failure] 45-45: [failure] 44-44: [failure] 43-43: 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function handleToggleChangeEvent( e ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| e.target.nextElementSibling.setAttribute( 'aria-checked', e.target.checked ? 'true' : 'false' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -47,6 +66,10 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( 'frm-send-test-email-btn' === e.target.id ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleClickSendTestEmailBtn( e ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if ( e.target.classList.contains( 'frm_dismiss_default_email_message' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| handleClickDismissDefaultEmailMessage( e ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| function handleClickChooseEmailStyle( e ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
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.
Duplicate
handleClickEventdefinitions break the new dismiss behaviorYou now have two top‑level
function handleClickEventdeclarations:.frm_dismiss_default_email_message.Because function declarations are hoisted, the second definition (lines 55–69) overwrites the first. The document click listener wired in
addEventListeners()will call only the second version, so clicks on the “Got it” link never trigger the dismiss AJAX call.This effectively disables the new banner dismissal.
I’d suggest merging the logic into a single
handleClickEvent:Optionally, you could also switch the
send_test_emailcall at the bottom to use the samedoJsonPostalias for consistency.Also applies to: 34-49, 55-69
🤖 Prompt for AI Agents