Commit 1492581
OCPBUGS-77912: Fix TypeError in OLS code import to console
The "Import to console" action from OpenShift Lightspeed was failing
with "TypeError: Cannot use 'in' operator to search for 'editor' in
undefined" when redirecting to the YAML import page.
The issue occurred in getEditor() where the 'in' operator was used on
monacoRef.current before checking if it was defined. This created a
race condition where the OLS code import useEffect would run when
editorMounted became true, but monacoRef.current was still undefined.
The fix adds a check to ensure monacoRef.current exists before using
the 'in' operator, preventing the TypeError and allowing the OLS code
to be properly injected into the editor.
Added regression tests to verify the fix handles all cases correctly.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 5ad72a8 commit 1492581
2 files changed
Lines changed: 40 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| |||
0 commit comments