Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Clutch
Commits
db158ec9
Unverified
Commit
db158ec9
authored
4 years ago
by
Derek
Committed by
GitHub
4 years ago
Browse files
Options
Download
Email Patches
Plain Diff
text field: fix date types with labels (#531)
parent
7fb42c59
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
frontend/packages/core/src/Input/stories/text-field.stories.tsx
+7
-0
...nd/packages/core/src/Input/stories/text-field.stories.tsx
frontend/packages/core/src/Input/text-field.tsx
+5
-1
frontend/packages/core/src/Input/text-field.tsx
with
12 additions
and
1 deletion
+12
-1
frontend/packages/core/src/Input/stories/text-field.stories.tsx
+
7
-
0
View file @
db158ec9
...
...
@@ -26,3 +26,10 @@ WithLabel.args = {
placeholder
:
""
,
label
:
"
TextField
"
,
};
export
const
WithType
=
Template
.
bind
({});
WithType
.
args
=
{
...
Primary
.
args
,
label
:
"
Date
"
,
type
:
"
datetime-local
"
,
};
This diff is collapsed.
Click to expand it.
frontend/packages/core/src/Input/text-field.tsx
+
5
-
1
View file @
db158ec9
...
...
@@ -29,6 +29,7 @@ const TextField: React.FC<TextFieldProps & MuiTextFieldProps> = ({
onReturn
,
maxWidth
,
placeholder
,
type
,
...
props
})
=>
{
const
onKeyDown
=
(
...
...
@@ -46,7 +47,9 @@ const TextField: React.FC<TextFieldProps & MuiTextFieldProps> = ({
color
:
"
secondary
"
,
}
as
Partial
<
InputLabelProps
>
;
if
(
placeholder
)
{
const
placeholderInputTypes
=
[
"
date
"
,
"
datetime-local
"
,
"
month
"
,
"
time
"
,
"
week
"
];
const
hasInputPlaceholder
=
placeholderInputTypes
.
indexOf
(
type
)
!==
-
1
;
if
(
placeholder
||
hasInputPlaceholder
)
{
inputLabelProps
.
shrink
=
true
;
}
...
...
@@ -59,6 +62,7 @@ const TextField: React.FC<TextFieldProps & MuiTextFieldProps> = ({
onFocus
=
{
onChange
}
onBlur
=
{
onChange
}
placeholder
=
{
placeholder
}
type
=
{
type
}
{
...
props
}
/>
);
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment