stopPropagationOfEnterAndSpace method

void stopPropagationOfEnterAndSpace(
  1. KeyboardEvent keyboardEvent
)

Because of the button decorator enclosing the inline portal eats up SPACE and ENTER key-presses (by preventing the default on them), we are stopping those events from bubbling up.

The button decorator only handles this in order to jump to the appropriate step. but, when we are already inside the step, we don't need those to "jump" to the same step there again. And hence, canceling the event from bubbling up.

Without this, when you have components inside that need the default behaviour of the SPACE or ENTER key-press (example: a material-input,) those components won't behave as expected (example: can't type a space in a material-input, or a new-line in multiline material input.)

Implementation

void stopPropagationOfEnterAndSpace(KeyboardEvent keyboardEvent) {
  int keyCode = keyboardEvent.keyCode;
  if (keyCode == KeyCode.ENTER || isSpaceKey(keyboardEvent)) {
    keyboardEvent.stopPropagation();
  }
}