Skip to content

Commit

Permalink
fix: Alter handling of cases where key value is not present (#13174) (#…
Browse files Browse the repository at this point in the history
…13200)

Fixes: #13004
Fixes: #13173

Co-authored-by: Tatu Lund <tatu@vaadin.com>
  • Loading branch information
vaadin-bot and TatuLund committed Mar 4, 2022
1 parent 4b5d82a commit 6055c6c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions flow-server/src/main/java/com/vaadin/flow/component/Key.java
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,12 @@ public interface Key extends Serializable {
*/
Key SUSPEND = Key.of("Suspend");

/**
* This value is reserved for corner cases of no key value present in event
* e.g. when browser autosuggest is used.
*/
Key NONE = Key.of("None");

/**
* Returns a {@link Key} instance for a printable representation of the key.
* <p>
Expand All @@ -2713,9 +2719,8 @@ public interface Key extends Serializable {
* @return the {@link Key} instance
*/
static Key of(String key, String... additionalKeys) {
Objects.requireNonNull(key);
if ("".equals(key)) {
throw new IllegalArgumentException("'key' cannot be empty");
if (key == null || "".equals(key)) {
return NONE;
}
List<String> keys = new ArrayList<>();
keys.add(key);
Expand Down

0 comments on commit 6055c6c

Please sign in to comment.