Skip to content

Commit

Permalink
Fix yaml-editor for new documents (again)
Browse files Browse the repository at this point in the history
The check for the querySelector chain should be that we found a
textArea, not that we found a textArea and it has a truthy value.

The empty string is falsey in JavaScript land, so checking !value
incorrectly meant we got the "DOM structure did not match" warning.
  • Loading branch information
richardTowers committed Nov 18, 2024
1 parent bff0387 commit a69b2cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/components/yaml-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ window.GOVUK.Modules = window.GOVUK.Modules || {}
'.app-c-govspeak-editor__preview-button-wrapper'
)
const textArea = innerContainer?.querySelector('#edition_body')
const value = textArea?.value
if (!value) {
if (!textArea) {
console.warn(
'YamlEditor: DOM structure did not match expectations, falling back to doing nothing'
)
return
}
const value = textArea.value

const monacoHostDiv = document.createElement('div')
monacoHostDiv.style.width = '100%'
Expand Down

0 comments on commit a69b2cd

Please sign in to comment.