-
Notifications
You must be signed in to change notification settings - Fork 132
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
Fix jQuery warnings as WordPress upgraded it from 1.12.4-wp to 3.5.1 #649
Conversation
@htdat I did test and I can see that the warnings no longer show up, that's great! I'm wondering though, how can we make sure that all the functionality is still the same? Do you have any steps to test for each change, or do we have any automated tests for those? Do we need to test across different browsers, operating systems, versions of WP? |
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.
I still see the warnings on two pages.
Do these warning not appear on your end? I also added define( 'EDIT_FLOW_VERSION' , '0.9.7-dev-' . time() );
to ensure that I'm not facing a caching problem while testing. Yet, on these two pages, the warnings remain.
Thanks for your review, @nielslange!
When looking at |
Well, that's tricky! We do not have automated tests for all of these jQuery changes. I am going to go through each of the changes and write up steps for testing. It looks like that for now https://d.pr/i/x8b4pQ I have reviewed 5/12 files today. I am changing this PR to Draft. After finishing the reviews for all 12 files, I will move it back.
Basically, this PR follows up all official guidelines from jQuery, I think testing in one environment (one browser, OS, and WP) is enough. Otherwise, if an issue happens, its cause is likey from jQuery, browser, OS, or WP. |
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.
Write down all possible test cases.
@@ -6,19 +6,19 @@ inlineEditUsergroup = { | |||
|
|||
t.what = '#usergroup-'; | |||
|
|||
$('.editinline').live('click', function(){ | |||
$( document ).on( 'click', '.editinline', function(){ |
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.
- Visit http://valet-vipgo-3279.test/wp-admin/admin.php?page=ef-user-groups-settings
- Hover on a group name, then click
Quick Edit
.
✅ if we're able to see relevant fields to update this group.
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.
This looks good but I found a bug related to this: #654
✅
inlineEditUsergroup.edit(this); | ||
return false; | ||
}); | ||
|
||
// prepare the edit row | ||
row.keyup(function(e) { if(e.which == 27) return inlineEditUsergroup.revert(); }); | ||
row.on( 'keyup', function(e) { if(e.which == 27) return inlineEditUsergroup.revert(); }); |
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.
- Visit http://valet-vipgo-3279.test/wp-admin/admin.php?page=ef-user-groups-settings
- Hover on a group name, then click
Quick Edit
. - See relevant fields to update this group, and try to edit some texts.
✅ if we press Escape
key and the Quick Edit
fields are closed and their values are reset.
Note: e.which == 27 here is equal to pressing "Escapce" key.
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.
✅
$('a.cancel', row).on( 'click', function() { return inlineEditUsergroup.revert(); }); | ||
$('a.save', row).on( 'click', function() { return inlineEditUsergroup.save(this); }); | ||
$('input, select', row).on( 'keydown', function(e) { if(e.which == 13) return inlineEditUsergroup.save(this); }); |
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.
- Visit http://valet-vipgo-3279.test/wp-admin/admin.php?page=ef-user-groups-settings
- Hover on a group name, then click
Quick Edit
. - See relevant fields to update this group, and try to edit some texts.
✅ if we click Cancel
button and the Quick Edit
fields are closed and their values are reset.
✅ if we click Update User Group
button and the Quick Edit
fields are saved then closed.
✅ if we press Enter
key and the Quick Edit
fields are saved then closed.
Note: e.which == 13
is for the Enter
key.
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.
✅
|
||
$('#posts-filter input[type="submit"]').mousedown(function(e){ | ||
$('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ |
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.
This seems redundant as there is no element with this ID posts-filter
in this page http://valet-vipgo-3279.test/wp-admin/admin.php?page=ef-user-groups-settings
Then this event is not triggered.
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.
Yeah this seems redundant. It looks like other pages like wp-admin/admin.php?page=ef-editorial-metadata-settings
use this but not User Groups
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.
Created #664
$("#toggle_details").on( 'click', function() { | ||
$(".post-title > p").toggle('hidden'); |
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.
TODO
I am going to remove this function as I am not able to find any element for $("#toggle_details")
:
- Only one result (exactly this line) with this search https://github.com/Automattic/Edit-Flow/search?q=toggle_details&type=
- Check on the HTML as well as browser console with this code:
jQuery("#toggle_details")
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.
Looks like toggle_details
was removed here:
95c6874
Safe to remove from this! ✅
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.
Created #663
@@ -50,7 +50,7 @@ | |||
var $filterTab = $('<li/>') | |||
.text(filter.label) | |||
.attr(options._filterIdAttr, i) | |||
.bind('click', _filterTabEvent) | |||
.on('click', _filterTabEvent) |
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.
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.
✅
.on('search', _filterInputSearch) | ||
.on('keydown', _filterInputKeydown) | ||
.on('keyup', _filterInputKeyup) |
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.
- Try editing a post.
- Find the
Notifications
section at the bottom.
✅ if we type some letters in the Search
field and the list below will be filtered in accordance with.
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.
✅
@@ -76,7 +76,7 @@ | |||
$input | |||
.addClass(options.inputPlaceholderClass) | |||
.val(options.inputPlaceholder) | |||
.focus(function() { | |||
.on( 'focus', function() { |
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.
See the comment in the L74 above:
// Fallback for browsers that don't support placeholders
I think this is a very low risk and we do not need a test case for it. Because it's difficult to find a browser not supporting placeholder nowadays: https://caniuse.com/input-placeholder
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.
✅
@@ -14,7 +14,7 @@ | |||
|
|||
// We need :contains to be case insensitive so lets redefine it as containsi (i for case insensitive) | |||
// http://stackoverflow.com/questions/187537/is-there-a-case-insensitive-jquery-contains-selector | |||
jQuery.expr[':'].containsi = function(a, i, m){ | |||
jQuery.expr.pseudos.containsi = function(a, i, m){ |
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.
- Try editing a post.
- Find the
Notifications
section at the bottom. - Search for both upper and lower cases for a specific user.
✅ if the filtered list always returns a result no matter the search input is upper or lower case.
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.
✅
@@ -251,7 +251,7 @@ | |||
if (o.altField) { | |||
tp_inst.$altInput = $(o.altField).css({ | |||
cursor: 'pointer' | |||
}).focus(function() { | |||
}).on ( 'focus', function() { |
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.
This is a library and it's being used for the Date
field in Editorial Metadata
module - related PR #169
We can see it in action when editing a post.
I see that the author has not changed this yet. I tried finding a way to test this file but it's not clear how I can replicate these events.
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.
Hmmm yeah this is a tough one....
I think as long as the date picker works we're good. I tested it on the post editing screen and it worked for me.
✅
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.
The author no longer maintains this library so I've created a new GH issue on our end to replace it.
@mikeyarce and @nielslange I've found out all the test cases for most changes here. Otherwise, I wrote down explanations and my researches for that. For each of these test cases, I also commented on the code change to verify my test cases correct. I also look at browser console when testing and writing these tests. To review those tests, it would be better to start here https://github.com/Automattic/Edit-Flow/pull/649/files |
@htdat excellent work with all these test cases and examples! I went through each one and tested them myself and I think this is good to go. I left a few comments about other things that I found but nothing to do with these changes. I think after merging this what would be nice would be:
What do you think? |
Oh, I must have missed that, @htdat. In that case, the PR looks good to me. |
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.
I've created 4 issues: 661 -> 644 to report issues raised from this PR.
@@ -251,7 +251,7 @@ | |||
if (o.altField) { | |||
tp_inst.$altInput = $(o.altField).css({ | |||
cursor: 'pointer' | |||
}).focus(function() { | |||
}).on ( 'focus', function() { |
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.
The author no longer maintains this library so I've created a new GH issue on our end to replace it.
@@ -169,11 +169,11 @@ jQuery(function ($) { | |||
|
|||
function focus_on_load() | |||
{ | |||
$('input[rel="' + options.randomElement + '"]').get(0).focus(); | |||
$('input[rel="' + options.randomElement + '"]').get(0).trigger( 'focus' ); |
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.
Created this issue #661
@@ -82,12 +82,12 @@ jQuery(document).ready(function() { | |||
} else if ( jQuery('select[name="_status"]').length > 0 ) { | |||
ef_append_to_dropdown('select[name="_status"]'); | |||
// Refresh the custom status dropdowns everytime Quick Edit is loaded | |||
jQuery('#the-list a.editinline').bind( 'click', function() { | |||
jQuery('#the-list a.editinline').on( 'click', function() { |
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.
Created #662
$("#toggle_details").on( 'click', function() { | ||
$(".post-title > p").toggle('hidden'); |
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.
Created #663
|
||
$('#posts-filter input[type="submit"]').mousedown(function(e){ | ||
$('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ |
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.
Created #664
|
||
$('#posts-filter input[type="submit"]').mousedown(function(e){ | ||
$('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ |
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.
Created #664
|
||
$('#posts-filter input[type="submit"]').mousedown(function(e){ | ||
$('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ |
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.
Created #664
@mikeyarce and @nielslange - thanks for your reviews!
I've created issues #660 -> #664 to track them. I am going to merge this PR now. 🙌 |
Fix #632
Description
This PR has done these changes to fix all warnings:
The following events are changed similarly to
click
above:blur, focus, focusin, focusout, resize, scroll, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave, change, select, submit, keydown, keypress, keyup, and contextmenu.
- refSteps to Test
Edit Flow
menu in wp-admin http://site.test/wp-admin/admin.php?page=ef-settingsConsole
in your browser.Console
tab.Note
You may apply this diff so that we can avoid the cache busting issue in browsers.