Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6184 from kevinansfield/fix-date-input
Fix changing text and jumping caret in PSM's date input
- Loading branch information
Showing
4 changed files
with
44 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Ember from 'ember'; | ||
import TextInputMixin from 'ghost/mixins/text-input'; | ||
import boundOneWay from 'ghost/utils/bound-one-way'; | ||
import {formatDate} from 'ghost/utils/date-formatting'; | ||
|
||
const {Component} = Ember; | ||
|
||
export default Component.extend(TextInputMixin, { | ||
tagName: 'span', | ||
classNames: 'input-icon icon-calendar', | ||
|
||
datetime: boundOneWay('value'), | ||
inputClass: null, | ||
inputId: null, | ||
inputName: null, | ||
|
||
didReceiveAttrs() { | ||
let datetime = this.get('datetime') || moment(); | ||
|
||
if (!this.attrs.update) { | ||
throw new Error(`You must provide an \`update\` action to \`{{${this.templateName}}}\`.`); | ||
} | ||
|
||
this.set('datetime', formatDate(datetime)); | ||
}, | ||
|
||
focusOut() { | ||
let datetime = this.get('datetime'); | ||
|
||
this.attrs.update(datetime); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{gh-input value=datetime | ||
id=inputId | ||
class=inputClass | ||
name=inputName | ||
stopEnterKeyDownPropagation="true"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters