Ghost/ghost/admin/app/components/gh-twitter-url-input.hbs
Kevin Ansfield c77c150745 Refactored facebook/twitter URL inputs
refs https://github.com/TryGhost/Ghost/issues/14101

Twitter/facebook URL validation doesn't follow our typical validation and was duplicated across multiple screens making the controllers unnecessarily complex.

- extracted url input fields and their validation into separate components
- uses tracked scratch values so that the input field values can reset to the saved value on save
  - twitter/facebook URL inputs are different to our other inputs because invalid values won't prevent saving, instead they are reset to their previous value on save
- added `this.validate()` call after a successful save in `settings` service so the service and underlying model validations are both in sync (fixes validation error sticking around after saving with invalid twitter/facebook values that have been reset)
2022-10-04 17:55:24 +01:00

10 lines
240 B
Handlebars

<input
type="url"
class="gh-input"
placeholder="https://twitter.com/username"
value={{this.value}}
{{on "input" this.setScratchValue}}
{{on "blur" this.setTwitterUrl}}
data-test-twitter-input
...attributes
/>