From 7b1df21aeb5d5de6d780007c74a3217b674c8794 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 21 Jun 2013 11:48:20 +0100 Subject: [PATCH] Delete default sort key if set to empty string Bug: 49724 Change-Id: Ie3caaf4811f87911444462f83d511c0cc46c0716 --- modules/ve/ui/dialogs/ve.ui.MWMetaDialog.js | 28 ++++++++++++--------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/ve/ui/dialogs/ve.ui.MWMetaDialog.js b/modules/ve/ui/dialogs/ve.ui.MWMetaDialog.js index 04c2e200f8..b42ba9dd98 100644 --- a/modules/ve/ui/dialogs/ve.ui.MWMetaDialog.js +++ b/modules/ve/ui/dialogs/ve.ui.MWMetaDialog.js @@ -179,18 +179,22 @@ ve.ui.MWMetaDialog.prototype.onClose = function ( action ) { } if ( this.defaultSortKeyChanged ) { - newDefaultSortKeyItemData = { - 'type': 'mwDefaultSort', - 'attributes': { 'content': this.defaultSortInput.getValue() } - }; - if ( currentDefaultSortKeyItem ) { - newDefaultSortKeyItem = new ve.dm.MWDefaultSortMetaItem( - ve.extendObject( {}, currentDefaultSortKeyItem.getElement(), newDefaultSortKeyItemData ) - ); - currentDefaultSortKeyItem.replaceWith( newDefaultSortKeyItem ); - } else { - newDefaultSortKeyItem = new ve.dm.MWDefaultSortMetaItem( newDefaultSortKeyItemData ); - this.metaList.insertMeta( newDefaultSortKeyItem ); + if ( this.defaultSortInput.getValue() !== '' ) { + newDefaultSortKeyItemData = { + 'type': 'mwDefaultSort', + 'attributes': { 'content': this.defaultSortInput.getValue() } + }; + if ( currentDefaultSortKeyItem ) { + newDefaultSortKeyItem = new ve.dm.MWDefaultSortMetaItem( + ve.extendObject( {}, currentDefaultSortKeyItem.getElement(), newDefaultSortKeyItemData ) + ); + currentDefaultSortKeyItem.replaceWith( newDefaultSortKeyItem ); + } else { + newDefaultSortKeyItem = new ve.dm.MWDefaultSortMetaItem( newDefaultSortKeyItemData ); + this.metaList.insertMeta( newDefaultSortKeyItem ); + } + } else if ( currentDefaultSortKeyItem ) { + currentDefaultSortKeyItem.remove(); } }