Skip to content

Commit

Permalink
Adds the inline text field to the view's parent rather than its pane.…
Browse files Browse the repository at this point in the history
… If any view in the chain from pane to the view's parent has a zIndex, the text field won't be visible. By adding it to the parent instead, there's a greater chance that nothing special will need to be done with the text field.
  • Loading branch information
publickeating committed Jan 20, 2013
1 parent 6df17cf commit 4d19990
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
22 changes: 11 additions & 11 deletions frameworks/foundation/delegates/inline_text_field.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

/**
@namespace
This is the default InlineEditorDelegate for SC.LabelView. The default editor
is an SC.InlineTextFieldView.
Expand All @@ -16,7 +16,7 @@
acquire if the active editor could not be discarded.
Each time an editor is required, it instantiates it and appends it to the same
pane as the view being edited. The editor is responsible for positioning
parentView as the view being edited. The editor is responsible for positioning
itself correctly in its beginEditing method.
@since SproutCore 1.0
Expand All @@ -35,8 +35,8 @@ SC.InlineTextFieldDelegate = /** @scope SC.InlineTextFieldDelegate */{
and if that fails attempting to dismiss. If that fails, the acquire fails
and returns null.
Otherwise, it creates the editor as a child of the client view's pane and
returns it.
Otherwise, it creates the editor as a child of the client view's parentView
and returns it.
The default editor is an SC.InlineTextFieldView. The client view may
customize this by setting a different inlineEditor as its exampleEditor
Expand All @@ -45,28 +45,28 @@ SC.InlineTextFieldDelegate = /** @scope SC.InlineTextFieldDelegate */{
@param {SC.InlineEditable} label the label that is requesting an editor
@returns {SC.InlineEditor} the editor the label should use to edit
*/
acquireEditor: function(label) {
acquireEditor: function (label) {
var editor = this.editor;

if(editor) {
if (editor) {
// attempt to end editing on the previous editor and return null if unable
// to end editing successfully
if(editor.get('isEditing') && !editor.commitEditing() && !editor.discardEditing()) return null;
if (editor.get('isEditing') && !editor.commitEditing() && !editor.discardEditing()) return null;

// now release it
this.releaseEditor(editor);
}

// default to SC.InlineTextFieldView
var exampleEditor = label.exampleEditor ? label.exampleEditor : SC.InlineTextFieldView,
pane = label.get('pane');
parentView = label.get('parentView');

// set ourself as the delegate for the editor
editor = this.editor = pane.createChildView(exampleEditor, {
editor = this.editor = parentView.createChildView(exampleEditor, {
inlineEditorDelegate: this
});

pane.appendChild(editor);
parentView.appendChild(editor);

return editor;
},
Expand All @@ -79,7 +79,7 @@ SC.InlineTextFieldDelegate = /** @scope SC.InlineTextFieldDelegate */{
@params {SC.InlineEditor} editor the editor that should be cleaned up
@returns {Boolean} whether the cleanup succeeded
*/
releaseEditor: function(editor) {
releaseEditor: function (editor) {
editor.removeFromParent();

this.editor = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,12 @@ test("basic acquire and release", function() {

ok(editor.kindOf(SC.InlineTextFieldView), "acquired an inlineTextFieldView");
same(editor.get('pane'), label.get('pane'), "editor created in the correct pane");
same(editor.get('parentView'), label.get('parentView'), "editor created in the correct parent");

SC.InlineTextFieldDelegate.releaseEditor(editor);

same(editor.get('pane'), null, "editor removed from pane after release");
same(editor.get('parentView'), null, "editor removed from parent view after release");
});

test("acquire custom editor", function() {
Expand Down

1 comment on commit 4d19990

@ksjun
Copy link

@ksjun ksjun commented on 4d19990 Feb 10, 2013

Choose a reason for hiding this comment

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

The 'pane' parameter of SC.InlineTextFieldView.positionOverTargetView also need to be changed to parentView.

Please sign in to comment.