Disallow recursively extending already extended references

Note that the duplicated search panel is most probably a temporary
solution anyway. We probably want a single search panel that can do
both kinds of "reuse with/without different details".

This is also inconsequential for production. Nothing related to
extended references is currently visible on production.

Added to the otherwise unrelated T369005 for code review purposes.

Bug: T369005
Change-Id: Iedee38dacc01ae59fb1a681e49e655ca91b25b64
This commit is contained in:
thiemowmde 2024-07-18 09:07:55 +02:00 committed by Thiemo Kreuz (WMDE)
parent f2146c043f
commit a62e855697

View file

@ -48,6 +48,7 @@ ve.ui.MWReferenceSearchWidget.static.isIndexEmpty = function ( internalList ) {
// Doing this live every time is cheap because it stops on the first non-empty group
for ( const groupName in groups ) {
if ( groupName.indexOf( 'mwReference/' ) === 0 && groups[ groupName ].indexOrder.length ) {
// No need to filter subrefs here, as it's impossible to have subrefs without parents
return false;
}
}
@ -143,6 +144,10 @@ ve.ui.MWReferenceSearchWidget.prototype.buildSearchIndex = function () {
const index = [];
const groupNames = Object.keys( groups ).sort();
// FIXME: Temporary hack, to be removed soon
// eslint-disable-next-line no-jquery/no-class-state
const filterExtends = this.$element.hasClass( 've-ui-citoidInspector-extends' );
for ( let i = 0; i < groupNames.length; i++ ) {
const groupName = groupNames[ i ];
if ( groupName.indexOf( 'mwReference/' ) !== 0 ) {
@ -159,6 +164,10 @@ ve.ui.MWReferenceSearchWidget.prototype.buildSearchIndex = function () {
if ( !refNode || refNode.getAttribute( 'placeholder' ) ) {
continue;
}
// FIXME: This might miss subrefs that are reused without repeating the extends attribute
if ( filterExtends && refNode.getAttribute( 'extendsRef' ) ) {
continue;
}
// Only increment counter for real references
n++;
const refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode( refNode );