Fix jQuery warnings as WordPress upgraded it from 1.12.4-wp to 3.5.1#649
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? |
nielslange
left a comment
There was a problem hiding this comment.
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. |
htdat
left a comment
There was a problem hiding this comment.
Write down all possible test cases.
| t.what = '#usergroup-'; | ||
|
|
||
| $('.editinline').live('click', function(){ | ||
| $( document ).on( 'click', '.editinline', function(){ |
There was a problem hiding this comment.
- 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.
This looks good but I found a bug related to this: #654
✅
|
|
||
| // 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.
- 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.
| $('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.
- 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.
| $('input, select', row).on( 'keydown', function(e) { if(e.which == 13) return inlineEditUsergroup.save(this); }); | ||
|
|
||
| $('#posts-filter input[type="submit"]').mousedown(function(e){ | ||
| $('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ |
There was a problem hiding this comment.
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.
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
| $("#toggle_details").on( 'click', function() { | ||
| $(".post-title > p").toggle('hidden'); |
There was a problem hiding this comment.
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.
Looks like toggle_details was removed here:
95c6874
Safe to remove from this! ✅
| .text(filter.label) | ||
| .attr(options._filterIdAttr, i) | ||
| .bind('click', _filterTabEvent) | ||
| .on('click', _filterTabEvent) |
| .on('search', _filterInputSearch) | ||
| .on('keydown', _filterInputKeydown) | ||
| .on('keyup', _filterInputKeyup) |
There was a problem hiding this comment.
- Try editing a post.
- Find the
Notificationssection at the bottom.
✅ if we type some letters in the Search field and the list below will be filtered in accordance with.
| .addClass(options.inputPlaceholderClass) | ||
| .val(options.inputPlaceholder) | ||
| .focus(function() { | ||
| .on( 'focus', function() { |
There was a problem hiding this comment.
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
| // 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.
- Try editing a post.
- Find the
Notificationssection 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.
| tp_inst.$altInput = $(o.altField).css({ | ||
| cursor: 'pointer' | ||
| }).focus(function() { | ||
| }).on ( 'focus', function() { |
There was a problem hiding this comment.
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.
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.
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. |
htdat
left a comment
There was a problem hiding this comment.
I've created 4 issues: 661 -> 644 to report issues raised from this PR.
| tp_inst.$altInput = $(o.altField).css({ | ||
| cursor: 'pointer' | ||
| }).focus(function() { | ||
| }).on ( 'focus', function() { |
There was a problem hiding this comment.
The author no longer maintains this library so I've created a new GH issue on our end to replace it.
| function focus_on_load() | ||
| { | ||
| $('input[rel="' + options.randomElement + '"]').get(0).focus(); | ||
| $('input[rel="' + options.randomElement + '"]').get(0).trigger( 'focus' ); |
| 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() { |
| $("#toggle_details").on( 'click', function() { | ||
| $(".post-title > p").toggle('hidden'); |
| $('input, select', row).on( 'keydown', function(e) { if(e.which == 13) return inlineEditMetadataTerm.save(this); }); | ||
|
|
||
| $('#posts-filter input[type="submit"]').mousedown(function(e){ | ||
| $('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ |
| $('input, select', row).on( 'keydown', function(e) { if(e.which == 13) return inlineEditUsergroup.save(this); }); | ||
|
|
||
| $('#posts-filter input[type="submit"]').mousedown(function(e){ | ||
| $('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ |
| $('input, select', row).on( 'keydown', function(e) { if(e.which == 13) return inlineEditCustomStatus.save(this); }); | ||
|
|
||
| $('#posts-filter input[type="submit"]').mousedown(function(e){ | ||
| $('#posts-filter input[type="submit"]').on( 'mousedown', function(e){ |
|
@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
clickabove: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 Flowmenu in wp-admin http://site.test/wp-admin/admin.php?page=ef-settingsConsolein your browser.Consoletab.Note
You may apply this diff so that we can avoid the cache busting issue in browsers.