Details
-
Bug
-
Resolution: Fixed
-
Critical
-
18.2.0-rc-1
-
Integration
-
Unknown
-
N/A
-
N/A
-
Description
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:
[[Test>>]]
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:
[[Test>>doc:Test.WebHome]]
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) { // We're probably creating a new link so there's no resource to preselect. 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:
[[label>>||anchor=Section]]
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.
Attachments
Issue Links
- is caused by
-
XWIKI-24119 Replace Typeahead with Tom Select in the Link dialog
-
- Closed
-
- is related to
-
XWIKI-24692 Creating a link to a page by pasting its full reference in the link modal is not always possible (anymore)
-
- Closed
-
-
XWIKI-22508 Creating a link in WYSIWYG by selecting text should follow the name strategy
-
- Closed
-
-
XWIKI-23154 Link creation dialog shouldn't allow to be validated without selecting a suggestion value
-
- Closed
-
- relates to
-
XWIKI-24860 Preselect the image resource reference as link target when creating a link from an image selection
-
- Open
-
-
XWIKI-24861 Create a URL or mailto link when the selected text looks like a URL or an email address
-
- Open
-