git.wincent.com
/
hextrapolate.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
c783ff7
)
Allow user to fully clear input field
author
Greg Hurrell <greg@hurrell.net>
Sat, 1 Aug 2015 03:00:15 +0000
(20:00 -0700)
committer
Greg Hurrell <greg@hurrell.net>
Sat, 1 Aug 2015 03:00:15 +0000
(20:00 -0700)
src/App.js
patch
|
blob
|
history
src/Field.react.js
patch
|
blob
|
history
diff --git
a/src/App.js
b/src/App.js
index 41aedb5eef156bddced99e76b1f09b39195273f9..87ca53fc3b4cc2421a447dd151400c7a9c3695b6 100644
(file)
--- a/
src/App.js
+++ b/
src/App.js
@@
-14,7
+14,7
@@
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
- value:
'0'
,
+ value:
null
,
};
}
diff --git
a/src/Field.react.js
b/src/Field.react.js
index 6bc42c27b8104030fb779643f304038f4fd55ba1..4dab605085aa8ef4b348bebf245bc1c7525b94c9 100644
(file)
--- a/
src/Field.react.js
+++ b/
src/Field.react.js
@@
-16,6
+16,9
@@
const DIGITS = '0123456789abcdef';
* Convert from canonical (hexadecimal) value to `base`.
*/
function fromValue(value: string, base: number): string {
+ if (value === null) {
+ return '';
+ }
if (base === 16) {
return value;
}
@@
-25,7
+28,10
@@
function fromValue(value: string, base: number): string {
/**
* Convert from `base` value to canonical (hexadecimal) value.
*/
-function toValue(value: string, base: number): string {
+function toValue(value: string, base: number): ?string {
+ if (value === '') {
+ return null;
+ }
if (base === 16) {
return value;
}