diff --git a/modules/ve-cite/ve.ui.MWReferenceEditPanel.js b/modules/ve-cite/ve.ui.MWReferenceEditPanel.js
index db7288e90..8f8e507c1 100644
--- a/modules/ve-cite/ve.ui.MWReferenceEditPanel.js
+++ b/modules/ve-cite/ve.ui.MWReferenceEditPanel.js
@@ -261,18 +261,21 @@ ve.ui.MWReferenceEditPanel.prototype.updateReuseWarningFromRef = function ( ref
* @param {ve.dm.MWReferenceModel} ref
*/
ve.ui.MWReferenceEditPanel.prototype.updateExtendsWarningFromRef = function ( ref ) {
- const mainRefId = this.internalList.keys.indexOf( ref.extendsRef );
- if ( mainRefId !== -1 ) {
- const itemNode = this.internalList.getItemNode( mainRefId );
- const $parentRefPreview = new ve.ui.MWPreviewElement( itemNode, { useView: true } ).$element;
+ if ( ref.extendsRef ) {
+ const mainRefId = this.internalList.keys.indexOf( ref.extendsRef );
this.extendsWarning.setLabel(
$( '
' )
.text( mw.msg( 'cite-ve-dialog-reference-editing-extends' ) )
- .append( $parentRefPreview )
+ .append( mainRefId === -1 ?
+ $( '
' )
+ .addClass( 've-ui-mwReferenceContextItem-muted' )
+ .text( ve.msg( 'cite-ve-dialog-reference-missing-parent-ref' ) ) :
+ new ve.ui.MWPreviewElement( this.internalList.getItemNode( mainRefId ), { useView: true } ).$element )
);
+ this.extendsWarning.toggle( true );
+ } else {
+ this.extendsWarning.toggle( false );
}
-
- this.extendsWarning.toggle( mainRefId !== -1 );
};
/**
diff --git a/tests/qunit/ve-cite/ve.ui.MWReferenceEditPanel.test.js b/tests/qunit/ve-cite/ve.ui.MWReferenceEditPanel.test.js
index 606ff3261..2291c3a66 100644
--- a/tests/qunit/ve-cite/ve.ui.MWReferenceEditPanel.test.js
+++ b/tests/qunit/ve-cite/ve.ui.MWReferenceEditPanel.test.js
@@ -46,12 +46,13 @@ QUnit.test( 'sub refs', ( assert ) => {
assert.false( editPanel.reuseWarning.isVisible() );
assert.true( editPanel.extendsWarning.isVisible() );
- assert.true( !!editPanel.extendsWarning.getLabel().text().indexOf( 'Bar' ) );
+ assert.true( editPanel.extendsWarning.getLabel().text().indexOf( 'Bar' ) !== -1 );
// test sub ref with missing main ref
ref.extendsRef = 'literal/notexist';
editPanel.setReferenceForEditing( ref );
assert.false( editPanel.reuseWarning.isVisible() );
- assert.false( editPanel.extendsWarning.isVisible() );
+ assert.true( editPanel.extendsWarning.isVisible() );
+ assert.true( editPanel.extendsWarning.getLabel().text().indexOf( 'cite-ve-dialog-reference-missing-parent-ref' ) !== -1 );
} );