import "./ProjectName.css"; import React, { Component } from "react"; import { selectNode, removeSelection } from "../utils"; type Props = { value: string; onChange: (value: string) => void; label: string; }; export class ProjectName extends Component { private handleFocus = (e: React.FocusEvent) => { selectNode(e.currentTarget); }; private handleBlur = (e: React.FocusEvent) => { const value = e.currentTarget.innerText.trim(); if (value !== this.props.value) { this.props.onChange(value); } removeSelection(); }; private handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter") { e.preventDefault(); e.currentTarget.blur(); } }; public render() { return ( {this.props.value} ); } }