Moving to next page doesn't work in FF 20.0.1 #33

Closed
wernerkrauss opened this Issue Apr 19, 2013 · 26 comments

Projects

None yet

4 participants

@wernerkrauss

Hi,

moving an item to next page doesn't work well in Firefox 20.0.1.

The next page arrow blinks but the item gets sorted somewhere on the current page.

Even making the button bigger (with firebug) doesn't work.

In IE9 it works

I run SS 3.0.5 and latest verion of SortableGridField

@wernerkrauss

Same in current chrome

@UndefinedOffset
Owner

Ok so in testing, is what your seeing that when you drop the item over the pagination arrows it goes to the edit screen?

@UndefinedOffset UndefinedOffset added a commit that referenced this issue Apr 19, 2013
@UndefinedOffset Fixed issue #33 were in newer browsers after dropping on the paginati…
…on arrows the edit screen would be displayed
4827b8e
@UndefinedOffset
Owner

I've pushed a change that addressed the issue I mention, give it a try. If that doesn't work re-open this ticket

@wernerkrauss

Hi,

yes, yesterday sometimes the edit screen was shown. but most of the time the item just juped to the last slot or one before. I updated the code and the current situation is:

The first time i try to move the last item on the page to the next page it works. But i don't see the item moving, just the mouse.

if i want to move another item, i see the item moving and slots "wandering" and i cannot move it to the next page but to a slot on the current page.

After reordering on the current page i cannot move anything (not even the last item) to another page.

Same in current Chrome.

Maybe a reload issue?

@UndefinedOffset
Owner

Are you using git master or tag 0.1.1 (both will be the same)? In my testing (Firefox 20.0.1 win, Chrome 26 win) it seems to be working as expected. In your test case what other fields (special ones like date pickers not plain text fields) do you have on the page, as well is it in a gridfield detail form? As well if you have firebug installed it should show you the last ajax request which will happen after you move any item. Can you see if there is an error coming back form the server? You should also be able to see this ajax request in the chrome developer tools network tab. If there is an error coming back mind posting the error and stack trace here?

@wernerkrauss

hi, i'm using branch master, latest commit 4827b8e (atm up to date).

It's a simple dataobject i try to sort, showing a thumbnail.

in my Dataobject:

    static $summary_fields = array (
        'Attachment' => 'Bild',
                'ShowInFooter' => 'Footer',
        'Title' => 'Titel',
        'Description' => 'Beschreibung',
    );

in my Page:

$fields are automatically created by silverssmith and/or parent class, but this shouldn't matter...

                $gridConf = $fields->dataFieldByName('ReferenzItems')->getConfig();

                $gridConf->addComponents(
                        new GridFieldSortableRows('SortOrder'),
                        new GridFieldBulkEditingTools(),
                        new GridFieldBulkImageUpload('AttachmentID')
        );
                if ($this->RootFolder()) {
                    $folderName = $this->RootFolder()->FileName;
                    $folderName = str_replace('assets/','',$folderName); 
                    $gridConf->getComponentByType('GridFieldBulkImageUpload')->setConfig('folderName',$folderName);
                }       
                return $fields;

Disabling the thumbnail i can now move items between pages.

but i need the thumbnail in this dataobject...

@UndefinedOffset
Owner

Very strange... I'll investigate tonight if I get a chance. If not it will be sometime next week before I get a chance.

@UndefinedOffset UndefinedOffset added a commit that referenced this issue Apr 26, 2013
@UndefinedOffset Resolved issue #33 when sorting to page the to page sort was called f…
…irst then the on page sort was called which caused the indexes to become confused
7cfaa47
@UndefinedOffset UndefinedOffset added a commit that referenced this issue Apr 26, 2013
@UndefinedOffset Resolved issue #33 when sorting to page the to page sort was called f…
…irst then the on page sort was called which caused the indexes to become confused
4de269e
@UndefinedOffset
Owner

Ok i think I've got it this time for sure, when sorting to page the to page sort was called first then the on page sort was called which caused the indexes to become confused. Like I said in my testing it is now not doing this. So try master, see if that works then let me know.

@wernerkrauss

It only works when i don't have an image thumbnail in my item summary.

With image i still cannot sort to another page.

Without image i see the mouse cursor changing and i see the "hand" when i'm over the next page arrow.

With thumbnail i only have the 4 arrow cursor.

Thanks for investigating on this issue!

@purplespider
Contributor

This still appears to be an issue when you have a thumbnail in the summary fields. Any plans to find a fix?

@UndefinedOffset
Owner

I've been having a really hard time reproducing it which is why its closed. That said if you can post some sample code that produces the issue and what version of silverstripe 3.x it is happening in I will look into it again.

@UndefinedOffset
Owner

Oh and any PHP errors or js errors ;)

@purplespider
Contributor

Ok, I've been trying to narrow this down to see if it's to do with my code or other modules, but somehow it's started working without any code changes!

However, when playing around with dev mode on, I have been experiencing quite a few Undefined offset Notices: http://spdr.me/V235 Sometimes the drag works, sometimes I get the error.

It seems to happen more often if I drag a record to the next page, then I go to that page, and drag a record from it to the first page.

It happens even if I remove my "Thumbnail" summary field.

When I do enable a Thumbnail summary field, drags to a different page seem very temperamental. Sometimes the drag works, other (most?) times it just ends up at the bottom of it's original page, without any errors.

Here is my DO code: http://spdr.me/wiNJ

I have also noticed at times that when looking in the database, a couple of the objects had the same sortOrder, not sure if this is related to either of the above!?

Any thoughts come from that?

@4t4r1
4t4r1 commented Jul 10, 2013

SortOrder is a bit of a fickle beast in both SS2 & SS3. Only triggered on create & sort, not delete, as far as I can ascertain -> have you checked the onAfter+BeforeCreate+Update+Delete funcs?

I've had rather nasty issues with them in the past...

@4t4r1
4t4r1 commented Jul 10, 2013

0x0F, hullo :) I think it's JS/jQ/AJAX related, something is not being triggered (that obviously should be..).
I've come across some fringe nonsense like this b4.
Cld b the browser itself...

Checked the onAfter+BeforeCreate+Update+Delete funcs & they're fine...

@purplespider what's the situation with JS errors ? Is it throwing any errs/notices ? 500s ? Firebugging ?

@purplespider
Contributor

The only errors I've seen are the 500's caused by the above undefined offset.

When a drag doesn't work, and the item just gets placed at the bottom of the current page, I couldn't see any errors at all, it's as if it just thinks you wanted to move it to the bottom of the page, and not to the next page. Even though the next arrow lit up blue.

@4t4r1
4t4r1 commented Jul 10, 2013

LOL!
0x0F == undefined offset (did u do this on purpose..).!.? :P

Are you using Firebug & does it throw any errors ?
If not / so, please tell the logging console to persist.

Dragging & dropping is not completely compatible across all browsers - it still needs to be hacked sometimes...

@UndefinedOffset
Owner

What version of SilverStripe are you guys using? 3.0.x, 3.1betaX, 3.1 git?

@purplespider
Contributor

The latest 3.1 master.

@UndefinedOffset
Owner

Looks like the notices your getting purplespider are causing the duplicate sort indexes. I'm working on resolving them atm. I'll update when I have a solution.

@UndefinedOffset
Owner

See if this helps with the issue you guys are having, something tells me it will at least with 3.1. As for the main point of why this issue was reported images causing issues. If commit 8b10f39 doesn't fix this try removing the image from the summary fields. Does that help? If not any JS errors or more php errors will be a huge help :)

@purplespider
Contributor

Ok, I had a play with this last night but was still getting undefined offset notices.

However, I've just had a good play now, and didn't receive a single one! So not sure what happened there.

Without an image field, it seems to work flawlessly, did loads of moves without a single fail.

But with an image field it still only seems to work 50% of the time in Firefox, the other 50% it just moves the item to the bottom of the current page without any PHP or JS errors.

In Safari, with images, it seems to be even worse, and I couldn't get a single item moved to a different page. Again, no errors.

@UndefinedOffset
Owner

Ya it seems to be a bug with jQuery UI when you have sortable and droppable basically sortable is handling the drop before droppable making the record sort on the current page.

That said if you get those notices that is likely a bug in my code that I should probably fix ;). I'll keep digging on the sortable/droppable issues but I can't guarantee anything.

@purplespider
Contributor

Ok, I've got a bet better at reproducing it: If the gridfield fits within the browser window without scrolling, then moving items works fine. If you have to scroll then moving items between pages breaks.

I thought it was the image summary field causing the issues, when in fact all that did was increase the height of the gridfield therefore requiring scrolling!

If I set the height of my thumbnails to 10, the gridfield fits on my screen all at once, and moving items works fine. Equally if I remove the image field, and then shrink the height of my browser window, moving items breaks again.

I'm wondering if it's something to do with the "jump" that happens when you begin to drag an item near the bottom of a list that you've had to scroll down.

@UndefinedOffset
Owner

The more i look and the more we discuss it, things are starting to point more and more to an issue with jQuery UI's Sortable and Droppable. I'd rather not introduce a newer version of jQuery UI into the cms since it revolves around jQuery UI. For now I'm going to close this issue as it seems to pertain more to an issue with jQuery UI then sortable gridfield.

If you find more notices coming from it feel free to open an issue pertaining to that notice.

@purplespider
Contributor

I did try the latest jQuery version, but the CMS didn't even load. :(

So looks like the best solution at the moment is to have a small or large number of items per page. A small number decreases the chance of needing to scroll down, meaning drags to other pages should work. Or a large number decreases the chances of there being multiple pages to drag to!

Thanks for being so active about this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment