Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events submit and cancel are mixed together in Textarea element #329

Open
paper-lark opened this issue Dec 26, 2017 · 0 comments
Open

Events submit and cancel are mixed together in Textarea element #329

paper-lark opened this issue Dec 26, 2017 · 0 comments

Comments

@paper-lark
Copy link

Calling both submit() and cancel() methods of a Textarea element eventually emits a cancel event despite which of them was called. Both methods are identical:

Textarea.prototype.submit = function() {
  if (!this.__listener) return;
  return this.__listener('\x1b', { name: 'escape' });
};

Textarea.prototype.cancel = function() {
  if (!this.__listener) return;
  return this.__listener('\x1b', { name: 'escape' });
};

Calling __listener() here in fact calls _listener due to the tethering done beforehand. Since the key.name is equal to 'escape', a call done(null, null) occurs inside the method. Inside done() either submit or a cancel event is emitted based on the second argument, value, which is the same in both cases. Here's the corresponding snippet of code:

if (err) {
  self.emit('error', err);
} else if (value != null) {
  self.emit('submit', value);
} else {
  self.emit('cancel', value);
}
self.emit('action', value);

Unless I'm missing something, all that means that both submit() and cancel() methods of the Textarea element in fact emit a cancel event.

@paper-lark paper-lark changed the title Confluence of submit and cancel events in Textarea element. Events submit and cancel are mixed together in Textarea element Dec 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant