• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scriptype / writ-cms / 27821996062

19 Jun 2026 11:05AM UTC coverage: 54.986% (-0.2%) from 55.191%
27821996062

push

github

scriptype
Fix form not submitting on Enter in input

because of the shadow dom boundary, an explicit bridge needed to
simulate native submit of form

642 of 1173 branches covered (54.73%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 1 file covered. (0.0%)

2242 of 4072 relevant lines covered (55.06%)

710.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cms/server/public/app/components/ContentEditor/TextField.js
1
import { LitElement, html } from 'lit'
2

3
class ContentEditorTextField extends LitElement {
4
  static formAssociated = true
×
5

6
  static properties = {
×
7
    value: { type: String },
8
    label: { type: String },
9
    name: { type: String },
10
    placeholder: { type: String }
11
  }
12

13
  constructor() {
14
    super()
×
15
    this.internals = this.attachInternals()
×
16
    this.value = ''
×
17
    this.label = 'Text'
×
18
    this.name = `text-field-${Date.now()}`
×
19
    this.placeholder = ''
×
NEW
20
    this.addEventListener('keydown', this.onKeyDown)
×
21
  }
22

23
  updated(changedProps) {
24
    if (changedProps.has('value')) {
×
25
      this.internals.setFormValue(this.value)
×
26
    }
27
  }
28

29
  onInput(e) {
30
    this.value = e.target.value
×
31
    this.internals.setFormValue(this.value)
×
32
  }
33

34
  onKeyDown(e) {
NEW
35
    if (e.key === 'Enter') {
×
NEW
36
      this.internals.form?.requestSubmit()
×
37
    }
38
  }
39

40
  render() {
41
    return html`
×
42
      <div class="content-editor-field">
43
        <label for="${this.name}-field">
44
          ${this.label}
45
        </label>
46
        <input
47
          type="text"
48
          @input="${this.onInput}"
49
          .value="${this.value}"
50
          placeholder="${this.placeholder}"
51
          id="${this.name}-field"
52
          name="${this.name}">
53
      </div>
54
    `
55
  }
56
}
57

58
customElements.define('content-editor-text-field', ContentEditorTextField)
×
59

60
export default ContentEditorTextField
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc