|
20 | 20 |
|
21 | 21 | package com.flowingcode.vaadin.addons.gridhelpers; |
22 | 22 |
|
| 23 | +import com.flowingcode.vaadin.jsonmigration.JsonMigration; |
23 | 24 | import com.vaadin.flow.component.ComponentUtil; |
24 | 25 | import com.vaadin.flow.component.UI; |
25 | 26 | import com.vaadin.flow.component.grid.Grid; |
26 | 27 | import com.vaadin.flow.component.grid.dataview.GridListDataView; |
27 | 28 | import com.vaadin.flow.shared.Registration; |
| 29 | +import elemental.json.JsonObject; |
28 | 30 | import java.io.Serializable; |
29 | 31 | import java.util.Optional; |
30 | 32 | import java.util.stream.Collectors; |
@@ -101,26 +103,27 @@ void enableEnhancedSelection() { |
101 | 103 | }); |
102 | 104 |
|
103 | 105 | keyUpRegistration = grid.getElement().addEventListener("keyup", ev -> { |
104 | | - String keyUp = ev.getEventData().getString(KEY_UP_EVENT_KEY); |
| 106 | + JsonObject eventData = JsonMigration.getEventData(ev); |
| 107 | + |
| 108 | + String keyUp = eventData.getString(KEY_UP_EVENT_KEY); |
105 | 109 | boolean arrowsKey = "ArrowDown".equals(keyUp) || "ArrowUp".equals(keyUp); |
106 | 110 |
|
107 | 111 | GridListDataView<T> dataView = grid.getListDataView(); |
108 | 112 |
|
109 | 113 | Optional<T> newFocusedItemMaybe = Optional.empty(); |
110 | | - int newFocusedItemIndex = |
111 | | - (int) ev.getEventData().getNumber(KEY_UP_ELEMENT_FOCUSED_ITEM_INDEX); |
| 114 | + int newFocusedItemIndex = (int) eventData.getNumber(KEY_UP_ELEMENT_FOCUSED_ITEM_INDEX); |
112 | 115 | if (newFocusedItemIndex >= 0) { |
113 | 116 | newFocusedItemMaybe = dataView.getItems().skip(newFocusedItemIndex).findFirst(); |
114 | 117 | } |
115 | 118 |
|
116 | 119 | if (newFocusedItemMaybe.isPresent()) { |
117 | 120 | T newFocusedItem = newFocusedItemMaybe.get(); |
118 | | - boolean isSpecialKey = ev.getEventData().getBoolean(KEY_UP_EVENT_META_KEY) |
119 | | - || ev.getEventData().getBoolean(KEY_UP_EVENT_CTRL_KEY) |
120 | | - || ev.getEventData().getBoolean(KEY_UP_EVENT_ALT_KEY); |
| 121 | + boolean isSpecialKey = eventData.getBoolean(KEY_UP_EVENT_META_KEY) |
| 122 | + || eventData.getBoolean(KEY_UP_EVENT_CTRL_KEY) |
| 123 | + || eventData.getBoolean(KEY_UP_EVENT_ALT_KEY); |
121 | 124 |
|
122 | 125 | Object lastFocusedItem = ComponentUtil.getData(grid, LAST_FOCUSED_ITEM); |
123 | | - boolean shiftKey = ev.getEventData().getBoolean(KEY_UP_EVENT_SHIFT_KEY); |
| 126 | + boolean shiftKey = eventData.getBoolean(KEY_UP_EVENT_SHIFT_KEY); |
124 | 127 | if (shiftKey) { |
125 | 128 | if (lastFocusedItem == null) { |
126 | 129 | ComponentUtil.setData(grid, LAST_FOCUSED_ITEM, newFocusedItem); |
|
0 commit comments