Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
6af78c45
Commit
6af78c45
authored
Jun 08, 2021
by
Eric Rosenbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hide validation message on click outside
parent
82ef1747
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
5 deletions
+17
-5
src/views/studio/studio-title.jsx
src/views/studio/studio-title.jsx
+17
-5
No files found.
src/views/studio/studio-title.jsx
View file @
6af78c45
...
...
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import
{
connect
}
from
'
react-redux
'
;
import
classNames
from
'
classnames
'
;
import
{
FormattedMessage
}
from
'
react-intl
'
;
import
onClickOutside
from
'
react-onclickoutside
'
;
import
{
selectStudioTitle
,
selectIsFetchingInfo
}
from
'
../../redux/studio
'
;
import
{
selectCanEditInfo
,
selectShowEditMuteError
}
from
'
../../redux/studio-permissions
'
;
...
...
@@ -31,6 +32,11 @@ const StudioTitle = ({
});
const
[
showMuteMessage
,
setShowMuteMessage
]
=
useState
(
false
);
const
[
hideValidationMessage
,
setHideValidationMessage
]
=
useState
(
false
);
StudioTitle
.
handleClickOutside
=
()
=>
{
setHideValidationMessage
(
true
);
};
return
(
<
div
...
...
@@ -45,10 +51,12 @@ const StudioTitle = ({
disabled=
{
isMutating
||
!
canEditInfo
||
isFetching
}
defaultValue=
{
title
}
onKeyDown=
{
e
=>
e
.
key
===
'
Enter
'
&&
e
.
target
.
blur
()
}
onBlur=
{
e
=>
e
.
target
.
value
!==
title
&&
handleUpdate
(
e
.
target
.
value
)
}
onBlur=
{
e
=>
{
if
(
e
.
target
.
value
!==
title
)
handleUpdate
(
e
.
target
.
value
);
setHideValidationMessage
(
false
);
}
}
/>
{
titleError
&&
<
ValidationMessage
{
titleError
&&
!
hideValidationMessage
&&
<
ValidationMessage
mode=
"error"
message=
{
<
FormattedMessage
id=
{
errorToMessageId
(
titleError
)
}
/>
}
/>
}
...
...
@@ -61,6 +69,10 @@ const StudioTitle = ({
);
};
const
clickOutsideConfig
=
{
handleClickOutside
:
()
=>
StudioTitle
.
handleClickOutside
};
StudioTitle
.
propTypes
=
{
titleError
:
PropTypes
.
string
,
canEditInfo
:
PropTypes
.
bool
,
...
...
@@ -71,7 +83,7 @@ StudioTitle.propTypes = {
handleUpdate
:
PropTypes
.
func
};
export
default
connect
(
export
default
onClickOutside
(
connect
(
state
=>
({
title
:
selectStudioTitle
(
state
),
canEditInfo
:
selectCanEditInfo
(
state
),
...
...
@@ -83,4 +95,4 @@ export default connect(
{
handleUpdate
:
mutateStudioTitle
}
)(
StudioTitle
);
)(
StudioTitle
)
,
clickOutsideConfig
)
;
Write
Preview
Markdown
is supported
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