Bartosz Dziewoński has uploaded a new change for review.
https://gerrit.wikimedia.org/r/187953
Change subject: ButtonElement: Unbreak 'pressed' state
......................................................................
ButtonElement: Unbreak 'pressed' state
I moved too much code to ButtonWidget when cleaning up the tabindex
hack from 9bd4eb3a. Partially revert the changes.
Bug: T88232
Change-Id: I51951cc5f348347894b05eb9ef57ceeb9c47c322
---
M src/elements/ButtonElement.js
M src/widgets/ButtonWidget.js
2 files changed, 5 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/53/187953/1
diff --git a/src/elements/ButtonElement.js b/src/elements/ButtonElement.js
index 6859cf2..5213a8c 100644
--- a/src/elements/ButtonElement.js
+++ b/src/elements/ButtonElement.js
@@ -80,6 +80,9 @@
return false;
}
this.$element.addClass( 'oo-ui-buttonElement-pressed' );
+ // Run the mouseup handler no matter where the mouse is when the button
is let go, so we can
+ // reliably remove the pressed class
+ this.getElementDocument().addEventListener( 'mouseup',
this.onMouseUpHandler, true );
// Prevent change of focus unless specifically configured otherwise
if ( this.constructor.static.cancelButtonMouseDownEvents ) {
return false;
@@ -96,6 +99,8 @@
return false;
}
this.$element.removeClass( 'oo-ui-buttonElement-pressed' );
+ // Stop listening for mouseup, since we only needed this once
+ this.getElementDocument().removeEventListener( 'mouseup',
this.onMouseUpHandler, true );
};
/**
diff --git a/src/widgets/ButtonWidget.js b/src/widgets/ButtonWidget.js
index 07768bb..d6a061d 100644
--- a/src/widgets/ButtonWidget.js
+++ b/src/widgets/ButtonWidget.js
@@ -93,10 +93,6 @@
OO.ui.ButtonWidget.prototype.onMouseDown = function ( e ) {
// Remove the tab-index while the button is down to prevent the button
from stealing focus
this.$button.removeAttr( 'tabindex' );
- // Run the mouseup handler no matter where the mouse is when the button
is let go, so we can
- // reliably reapply the tabindex and remove the pressed class
- this.getElementDocument().addEventListener( 'mouseup',
this.onMouseUpHandler, true );
-
return OO.ui.ButtonElement.prototype.onMouseDown.call( this, e );
};
@@ -106,9 +102,6 @@
OO.ui.ButtonWidget.prototype.onMouseUp = function ( e ) {
// Restore the tab-index after the button is up to restore the button's
accessibility
this.$button.attr( 'tabindex', this.tabIndex );
- // Stop listening for mouseup, since we only needed this once
- this.getElementDocument().removeEventListener( 'mouseup',
this.onMouseUpHandler, true );
-
return OO.ui.ButtonElement.prototype.onMouseUp.call( this, e );
};
--
To view, visit https://gerrit.wikimedia.org/r/187953
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I51951cc5f348347894b05eb9ef57ceeb9c47c322
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits