Listen to the user hitting enter in the lock/unlock modal input fields (#505)

* Listen to the user hitting enter in the lock/unlock modal input fields

Listen to both, just in case one or the other is disabled

* Don't require that the element exist
This commit is contained in:
gbrodman 2020-03-10 11:22:57 -04:00 committed by GitHub
parent dda9b90587
commit a9cfa1dc96

View file

@ -91,7 +91,7 @@ registry.registrar.RegistryLock.prototype.fillLocksPage_ = function(e) {
lockEnabledForContact: locksDetails.lockEnabledForContact}); lockEnabledForContact: locksDetails.lockEnabledForContact});
if (locksDetails.lockEnabledForContact) { if (locksDetails.lockEnabledForContact) {
// Listen to the lock-domain 'submit' button click as well as the enter key // Listen to the lock-domain 'submit' button click
var lockButton = goog.dom.getRequiredElement('button-lock-domain'); var lockButton = goog.dom.getRequiredElement('button-lock-domain');
goog.events.listen(lockButton, goog.events.EventType.CLICK, this.onLockDomain_, false, this); goog.events.listen(lockButton, goog.events.EventType.CLICK, this.onLockDomain_, false, this);
// For all unlock buttons, listen and perform the unlock action if they're clicked // For all unlock buttons, listen and perform the unlock action if they're clicked
@ -129,12 +129,29 @@ registry.registrar.RegistryLock.prototype.showModal_ = function(targetElement, d
false, false,
this); this);
// Listen to the "submit" click and also the user hitting enter
goog.events.listen( goog.events.listen(
goog.dom.getRequiredElement('domain-lock-submit'), goog.dom.getRequiredElement('domain-lock-submit'),
goog.events.EventType.CLICK, goog.events.EventType.CLICK,
e => this.lockOrUnlockDomain_(isLock, e), e => this.lockOrUnlockDomain_(isLock, e),
false, false,
this); this);
[goog.dom.getElement('domain-lock-password'),
goog.dom.getElement('domain-lock-input-value')].forEach(elem => {
if (elem != null) {
goog.events.listen(
elem,
goog.events.EventType.KEYPRESS,
e => {
if (e.keyCode === goog.events.KeyCodes.ENTER) {
this.lockOrUnlockDomain_(isLock, e);
}
},
false,
this);
}
});
} }
/** /**