Steps to reproduce
- Edit a page with the WYSIWYG editor (CKEditor).
- Type some text, e.g. Test.
- Select that text and open the link dialog (toolbar button or Ctrl+K).
- Leave the Page field untouched and validate the dialog.
- Save the page.
Actual result The link has an empty target, so it points to the page itself:
Nothing warns the user, and the only way out is to edit the wiki source. Expected result A link to a new page named after the selected text, as before 18.2.0:
Cause Regression of XWIKI-22508 caused by XWIKI-24119. Confirmed by Marius. Until 18.1.x, opening the link dialog with a text selection pre-filled the Page field with a new-page reference computed from the selected text by CKEditor.LinkNameStrategyHelper (getDefaultResourceReference() and setDefaultValue() in xwiki-link/plugin.js, added by XWIKI-22508), so validating the dialog without touching anything created the link to the new page. XWIKI-24119 removed that pre-fill, and the field now opens empty:
setup: function(data) {
let resourceReference = data.resourceReference;
if (!resourceReference) {
return;
The empty target is not rejected either, because of a second problem: in xwiki-resource/plugin.js, validate() accepts an empty reference as soon as the resource type declares allowEmptyReference, which the doc type does (in resource/resource.js) - legitimately, since that is what allows anchor-only links such as:
As a result the mustBeSelected check added by XWIKI-23154 sits in the else if branch and is never reached for an empty field, so the dialog validates silently. No functional test covers "select text, open the link dialog, validate", which is why the removal went unnoticed. Workaround Type the page name in the Page field and select "Create new page..." (or "Create with exact reference...") from the suggestions; typed text alone is discarded by the suggest widget. The page-creation node of the tree picker also works. To be decided Marius: pre-filling the suggest (preselecting a value based on the link label) is fine, but we need to decide between "Create with exact reference" and "Create new page" (relative to the current location), the two options offered when you type the link label yourself in the suggest input. Independently of that choice, the empty-reference validation for the doc type should probably be tightened so that an empty reference is only accepted when an anchor or a query string is set, otherwise this silent self-link stays reachable. |