Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Commit

Permalink
feat: added handler for enter button
Browse files Browse the repository at this point in the history
  • Loading branch information
UvgenGen committed Sep 14, 2022
1 parent b20b172 commit 217235f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/library-authoring/author-library/LibraryAuthoringPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ const deriveTypeOptions = (blockTypes, intl) => {
*/
const LibraryAuthoringPageHeaderBase = ({ intl, library, ...props }) => {
const [inputIsActive, setIsActive] = useState(false);
const handleOnBlur = (event) => {
const handleSaveTitle = (event) => {
const newTitle = event.target.value;
if (newTitle && newTitle !== library.title) {
props.updateLibrary({ data: { title: newTitle, libraryId: library.id } });
Expand All @@ -360,7 +360,10 @@ const LibraryAuthoringPageHeaderBase = ({ intl, library, ...props }) => {
type="text"
aria-label="Title input"
defaultValue={library.title}
onBlur={handleOnBlur}
onBlur={handleSaveTitle}
onKeyDown={event => {
if (event.key === 'Enter') { handleSaveTitle(event) }
}}
/>
)
: (
Expand Down

0 comments on commit 217235f

Please sign in to comment.