* returns the widget that contains the target * @param {HTMLElement} target * @returns {Widget}
(target)
| 202 | * @returns {Widget} |
| 203 | */ |
| 204 | getWidgetFromTarget(target) { |
| 205 | // TODO: improve search, currently O(n), but can be improved via this.widgets or something |
| 206 | |
| 207 | let innerWidget = null |
| 208 | for (let [key, ref] of Object.entries(this.widgetRefs.current)) { |
| 209 | |
| 210 | if (ref.current === target) { |
| 211 | innerWidget = ref.current |
| 212 | break |
| 213 | } |
| 214 | |
| 215 | // console.log("refs: ", ref) |
| 216 | // TODO: remove the ref.current? if there are bugs it would become hard to debug |
| 217 | if (ref.current?.getElement().contains(target)) { |
| 218 | |
| 219 | if (!innerWidget) { |
| 220 | innerWidget = ref.current |
| 221 | } else if (innerWidget.getElement().contains(ref.current.getElement())) { |
| 222 | // If the current widget is deeper than the existing innermost widget, update innerWidget |
| 223 | innerWidget = ref.current |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | return innerWidget |
| 229 | } |
| 230 | |
| 231 | keyDownEvent(event) { |
| 232 |
nothing calls this directly
no outgoing calls
no test coverage detected