DLynch has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/362229 )
Change subject: ui.FormatAction: fixup selection for empty conversions
......................................................................
ui.FormatAction: fixup selection for empty conversions
Converting an empty node needs a small selection fixup afterwards, otherwise
the selection will be displayed outside the new empty node. This causes issues
with the display of the current format in the toolbar, and with hitting enter
if no content is entered. Don't always reapply the selection, because the
automatic behavior is better if isolateAndUnwrap has actually acted.
Bug: T151594
Change-Id: Ibf143e7954919d0d9efacd53205d5451461a3115
---
M src/ui/actions/ve.ui.FormatAction.js
1 file changed, 11 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor
refs/changes/29/362229/1
diff --git a/src/ui/actions/ve.ui.FormatAction.js
b/src/ui/actions/ve.ui.FormatAction.js
index eb4fdce..d3ed91b 100644
--- a/src/ui/actions/ve.ui.FormatAction.js
+++ b/src/ui/actions/ve.ui.FormatAction.js
@@ -51,9 +51,10 @@
var selected, i, length, contentBranch,
surfaceModel = this.surface.getModel(),
fragment = surfaceModel.getFragment(),
+ fragmentSelection = fragment.getSelection(),
fragments = [];
- if ( !( fragment.getSelection() instanceof ve.dm.LinearSelection ) ) {
+ if ( !( fragmentSelection instanceof ve.dm.LinearSelection ) ) {
return;
}
@@ -73,6 +74,15 @@
}
fragment.convertNodes( type, attributes );
+ if ( fragment.getData().length === 0 ) {
+ // Converting an empty node needs a small selection fixup
afterwards,
+ // otherwise the selection will be displayed outside the new
empty
+ // node. This causes issues with the display of the current
format in
+ // the toolbar, and with hitting enter if no content is
entered. Don't
+ // always reapply the selection, because the automatic behavior
is
+ // better if isolateAndUnwrap has actually acted. (T151594)
+ surfaceModel.setSelection( fragmentSelection );
+ }
this.surface.getView().focus();
return true;
};
--
To view, visit https://gerrit.wikimedia.org/r/362229
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf143e7954919d0d9efacd53205d5451461a3115
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits