Skip to content
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

BUG Make UI widget destroys more consistent to avoid exceptions. #3286

Merged
merged 1 commit into from Jul 17, 2014

Conversation

mateusz
Copy link
Contributor

@mateusz mateusz commented Jul 13, 2014

Selectable would throw an exception in the GridField.js if destroy
called from onunmatch - at that stage jQuery UI would have had called
the destroy already. Add a guard, and change to onremove, which triggers
before the element is removed from DOM.

@tractorcow
Copy link
Contributor

Probably should use this._super() in onadd and onremove

@silverstripe silverstripe locked and limited conversation to collaborators Jul 14, 2014
@silverstripe silverstripe unlocked this conversation Jul 14, 2014
@mateusz
Copy link
Contributor Author

mateusz commented Jul 14, 2014

Don't merge yet, still testing.

@mateusz
Copy link
Contributor Author

mateusz commented Jul 14, 2014

Ok, I think it's ready.

},

onunmatch: function() {
this._super();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any benefit to this? It does nothing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It makes onmatch work. If onmatch is present, but onunmatch isn't, onmatch might short-circuit bypassing some handlers.

@mateusz
Copy link
Contributor Author

mateusz commented Jul 14, 2014

Removed that fine example of a cargo-cult programming.

},

onunmatch: function() {
this._super();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't our revelation that onunmatch relies on onmatch, but not the other way around?

@mateusz
Copy link
Contributor Author

mateusz commented Jul 17, 2014

Fixed up.

@tractorcow
Copy link
Contributor

Perfect. Will merge, but can you please squash your commits?

1. Add missing _super calls.

2. Make UI widget destroys more consistent to avoid exceptions.
Selectable would throw an exception in the GridField.js if destroy
called from onunmatch - at that stage jQuery UI would have had called
the destroy already. Add a guard, and change to onremove, which triggers
before the element is removed from DOM.

3. DOM traversal fails after the element is removed from DOM.
Onunmatch triggers after the removal of the element from the DOM, which
makes DOM traversal fail. Use onremove instead, which triggers while the
element is still in DOM.
@mateusz
Copy link
Contributor Author

mateusz commented Jul 17, 2014

'ere, squished.

@tractorcow
Copy link
Contributor

Ok, hope all the tests pass.

tractorcow pushed a commit that referenced this pull request Jul 17, 2014
BUG Make UI widget destroys more consistent to avoid exceptions.
@tractorcow tractorcow merged commit f16306d into silverstripe:3.1 Jul 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants