Page MenuHomePhabricator

VisualEditor: Highlighted trailing whitespace should not have styles applied
Closed, ResolvedPublic

Description

This is a classic problem in at least 10 other "web page editors" for other products, plus VisualEditor.

Consider the sentence: Hello world.

  1. Highlight the word "Hello " including the space character after it.
  2. Click the "Bold" button.
  3. It renders:

    <b>Hello </b>World

when what the user REALLY wanted was:

<b>Hello</b> World

Even if the user highlighted the whitespace, 99.9% of the time he/she doesn't really want it bolded. VisualEditor should bold only "Hello" and not the space after it.

The original MediaWiki edit page is the only editor I've ever seen that gets it right. If you highlight "Hello " with a trailing space and click the bold button, you get '''Hello'''. Hooray! Please don't lose this in VisualEditor.

This may be related to bug 22487, but that's for UsabilityInitiative and linking.


Version: unspecified
Severity: normal

Details

Reference
bz33108
TitleReferenceAuthorSource BranchDest Branch
Remove unused custom Elasticsearch backend coderepos/phabricator/extensions!26aklapperT351085rmElasticsearchwmf/stable
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:01 AM
bzimport set Reference to bz33108.

Just a note: the behavior described at
https://www.mediawiki.org/w/index.php?title=Visual_editor/Feedback&oldid=552919#Double_click_selects_spaces
makes it very common to have spaces in the end of the selected text.

Confirmed that this is still the behaviour of the new version.

Should we trim-and-then-apply? Or apply, but then trim on save? If the latter, won't that screw with wikitext<->Visual Editor cleanness of conversions? If the former, will this be unexpected (e.g. people selected the space deliberately so that they could later insert some bold text after it)?

The use-case is:

  1. User double-clicks a word
  2. User clicks the Bold button

So "trim-and-then-apply" is the right thing to do 99% of the time.

If this helps... in 25+ years of editing, I can't think of a time I intentionally selected the space after a word in order to style it.

Actually, "trim-and-then-apply" is not precisely correct. You want "trim and move the highlighted space to be after the closing bold marker."

Mass-moving items into VisualEditor product

Agree that trim-selection-then-redraw-then-apply is appropriate iff the user has used a bulk-text-auto-selector (like double-click on word).

But are we sure on when they have actively gone out of their way to select the preceding/trailing space (shift-cursors, etc.)?

Mass-move out of "General" to "ContentEditable".

Add to "VE-deploy-2012-07-09" milestone per this morning's meeting.