Page MenuHomePhabricator

[jquery.textSelection] Select sample text, if possible, when splitlines is true
Closed, ResolvedPublic

Description

Steps to reproduce:

  1. Open any page for editing, open the "Advanced" toolbar from WikiEditor.
  2. Click the icon for inserting a list.

Expected result: The sample text "Bulleted list item" is selected.
Actual result: It is not.

If you don't have WikiEditor installed, you can execute

$( '#wpTextbox1' ).textSelection( 'encapsulateSelection', {
pre: '* ',
post: '\n',
peri: 'item',
selectPeri: true,
splitlines: true
} );

instead of step 2 (which also shows that this indeed is an issue with jquery.textSelection, and not with WikiEditor).


Version: 1.24rc
Severity: enhancement
Whiteboard: gci2014

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 22 2014, 3:55 AM
bzimport set Reference to bz70764.
bzimport added a subscriber: Unknown Object (MLST).

selectPeri is documented (in code) not to work with splitlines:

selectPeri: true, // Select the peri text if it was inserted (but not if there was a selection and replace==false, or if splitlines==true)
splitlines: false, // If multiple lines are selected, encapsulate each line individually

The code and comments are clear that this is intentional and by design, and there even is a test for this behavior. I'm not sure if we should change it.

Hm. Blame tells me that I reported the bug for which this was changed: Bug 29105. Of course, when the sample text can't be selected (because it is splitted into multiple parts) it shouldn't be selected. But if it can, it should, and in most cases there shouldn't be newlines in the sample text, so it won't get split up.
When you use WikiEditor to insert a list, you want to override the sample text. Why should you have to select it yourself to do so?

Hmm. Okay, that's actually reasonable.

I've claimed this task in GCI2014, and am waiting for it to be assigned to me there. https://www.google-melange.com/gci/task/view/google/gci2014/5791881946464256
Feel free to assign me to it here as well.

I was looking at the code, and it seems that the simplest thing to do would be to just check if the text contains a newline.

Huh, the code for IE works differently. I tried it on IE 8 and it already works as expected – the example test is selected. Amusing.

It didn't work for me on IE11. Perhaps it's using the standards-compliant path?

Change 177986 had a related patch set uploaded (by Gerrit Patch Uploader):
Fix T72764 - [jquery.textSelection] Select sample text, if possible, when splitlines is true

https://gerrit.wikimedia.org/r/177986

Patch-For-Review

Change 177986 had a related patch set uploaded (by Bartosz Dziewoński):
jquery.textSelection: Select sample text, if possible, when splitlines is true

https://gerrit.wikimedia.org/r/177986

Patch-For-Review

matmarex assigned this task to Scimonster.
matmarex removed a project: Patch-For-Review.
matmarex removed a subscriber: Unknown Object (MLST).

Change 177986 merged by jenkins-bot:
jquery.textSelection: Select sample text, if possible, when splitlines is true

https://gerrit.wikimedia.org/r/177986