WordPress.org

Ready to get started?Download WordPress

Forums

Simple Page Ordering
[resolved] TypeError: i.querySelector(...) is null (4 posts)

  1. nonverbla
    Member
    Posted 10 months ago #

    Hi there!

    First of all: Using and loving your plugin ever since it's release!

    In the newest release though, there is a bug: When re-ordering, the spinning wheel stays and I get a javascript error saying
    TypeError: i.querySelector(...) is null

    It happens on the normal posts edit screen, which I activated following your instructions. On the pages edit screen, it works fine.

    Testing it there, I just found another "bug": When you use the translation plugin qtranslate, the title of posts / pages always has to go through the default post title filters, so that language brackets won't get printed. After reordering, I think because the updated post title comes from your javascript, the title says something like this:

    <!--:en-->About<!--:--><!--:de-->Über uns<!--:-->

    When I reload the page, the title is displayed correctly again.

    I both cases, actual re-ordering works fine, both errors just make the plugin 'feel broken'.

    Hopefully, the hints will be helpful for you.

    http://wordpress.org/extend/plugins/simple-page-ordering/

  2. Jake Goldman
    10up Engineer
    Plugin Author

    Posted 10 months ago #

    Totally missed a bug in my testing where custom post types that had EITHER page-attributes or hierarchical support (but not both) would break. Fixed in 2.1.1!

    Not planning to add special support for qTranslate, which does some really janky stuff to accomplish its goal, but patches would be welcome...

  3. nonverbla
    Member
    Posted 10 months ago #

    Hi Jake, thank you very much, the js-error is gone with the new version!

    Concerning the problems with qtranslate, I figured out what the problem is. Your script gets the updated post title from the hidden quick-edit field ".post_title", which isn't converted by qtranslate. Actually, I totally forgot about the quick-edit feature over the years, because in my setups, it is always deactivated ;)

    I 'fixed' this by replacing this line in your code (line 25 in dev.js):

    var post_title = inline_key.querySelector('.post_title').innerHTML;

    ...with this:

    var post_title = inline_key.parentNode.querySelector('.row-title').innerHTML;
    
    while(post_title.indexOf("— ") == 0){
        post_title = post_title.substr(2);
    }

    I can imagine, that this method is even more future-proof, because it is based on the field the user actually sees before re-ordering.

    What are your thoughts?

  4. nonverbla
    Member
    Posted 10 months ago #

    Hi again,
    I have written a workaround. Load this js in the edit.php, it will fix the "error" with the qtranslate brackets:

    $(document).ready(function(){
        // Replace the .post_title with the .row-title, so that titles won't seem broken after re-ordering
        $(".edit-php .wp-list-table .column-title").each(function(){
            $(this).find(".post_title").text($(this).find(".row-title").text());
        })
    })

Reply

You must log in to post.

About this Plugin

About this Topic