mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-09-28 21:06:25 +00:00
Merge "New topic tool: Show empty title warning only when focussing the description"
This commit is contained in:
commit
22bb9d9b42
|
@ -102,7 +102,7 @@ NewTopicController.prototype.setupReplyWidget = function ( replyWidget, data ) {
|
|||
}
|
||||
|
||||
this.sectionTitle.connect( this, { change: 'onSectionTitleChange' } );
|
||||
this.sectionTitle.$input.on( 'blur', this.onSectionTitleBlur.bind( this ) );
|
||||
this.replyWidget.connect( this, { bodyFocus: 'onBodyFocus' } );
|
||||
|
||||
replyWidget.connect( this, {
|
||||
clear: 'clear',
|
||||
|
@ -247,19 +247,23 @@ NewTopicController.prototype.onSectionTitleChange = function () {
|
|||
};
|
||||
|
||||
/**
|
||||
* Handle 'blur' events for the section title input.
|
||||
* Handle 'focus' events for the description field (regardless of mode).
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
NewTopicController.prototype.onSectionTitleBlur = function () {
|
||||
NewTopicController.prototype.onBodyFocus = function () {
|
||||
var offsetBefore = this.replyWidget.$element.offset().top;
|
||||
var rootScrollable = OO.ui.Element.static.getRootScrollableElement( document.body );
|
||||
var scrollBefore = rootScrollable.scrollTop;
|
||||
|
||||
this.checkSectionTitleValidity();
|
||||
|
||||
var offsetChange = this.replyWidget.$element.offset().top - offsetBefore;
|
||||
// Ensure the rest of the widget doesn't move when the validation
|
||||
// message is triggered by a blur. (T275923)
|
||||
window.scrollBy( 0, offsetChange );
|
||||
// message is triggered by a focus. (T275923)
|
||||
// Browsers sometimes also scroll in response to focus events,
|
||||
// so use the old scrollTop value for consistent results.
|
||||
rootScrollable.scrollTop = scrollBefore + offsetChange;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -45,6 +45,7 @@ ReplyWidgetPlain.prototype.createReplyBodyWidget = function ( config ) {
|
|||
textInput.$input.attr( 'aria-label', config.placeholder );
|
||||
// Fix jquery.ime position (T255191)
|
||||
textInput.$input.addClass( 'ime-position-inside' );
|
||||
|
||||
return textInput;
|
||||
};
|
||||
|
||||
|
@ -89,6 +90,7 @@ ReplyWidgetPlain.prototype.setup = function ( data ) {
|
|||
|
||||
// Events
|
||||
this.replyBodyWidget.connect( this, { change: this.onInputChangeThrottled } );
|
||||
this.replyBodyWidget.$input.on( 'focus', this.emit.bind( this, 'bodyFocus' ) );
|
||||
|
||||
this.replyBodyWidget.setValue( data.value || autosaveValue );
|
||||
|
||||
|
|
|
@ -95,6 +95,10 @@ ReplyWidgetVisual.prototype.setup = function ( data ) {
|
|||
this.replyBodyWidget.setDocument( htmlOrDoc );
|
||||
|
||||
target.once( 'surfaceReady', function () {
|
||||
target.getSurface().getView().connect( widget, {
|
||||
focus: [ 'emit', 'bodyFocus' ]
|
||||
} );
|
||||
|
||||
target.getSurface().getModel().setAutosaveDocId( widget.storagePrefix );
|
||||
target.initAutosave();
|
||||
widget.afterSetup();
|
||||
|
|
Loading…
Reference in a new issue