diff --git a/src/admin/components/forms/DraggableSection/SectionTitle/EditableBlockTitle/index.scss b/src/admin/components/forms/DraggableSection/SectionTitle/EditableBlockTitle/index.scss deleted file mode 100644 index 0136f03e69..0000000000 --- a/src/admin/components/forms/DraggableSection/SectionTitle/EditableBlockTitle/index.scss +++ /dev/null @@ -1,46 +0,0 @@ -@import '../../../../../scss/styles.scss'; - -.editable-block-title { - position: relative; - z-index: 1; - display: flex; - max-width: 100%; - overflow-x: auto; - - &__input-clone { - position: absolute; - top: 0; left: 0; - visibility: hidden; - white-space: pre; - } - - &__input-clone, - input { - padding: base(.1) base(.2); - font-family: $font-body; - font-weight: 600; - margin-right: base(.5); - font-size: base(.75); - color: $color-dark-gray - } - - input { - border: none; - width: 100%; - margin-left: base(.5); - background-color: transparent; - - &:hover { - box-shadow: inset 0px -2px 0px -1px $color-light-gray; - } - - &:hover, - &:focus { - outline: 0; - } - - &:focus { - box-shadow: none; - } - } -} diff --git a/src/admin/components/forms/DraggableSection/SectionTitle/EditableBlockTitle/index.tsx b/src/admin/components/forms/DraggableSection/SectionTitle/EditableBlockTitle/index.tsx deleted file mode 100644 index 87a616642f..0000000000 --- a/src/admin/components/forms/DraggableSection/SectionTitle/EditableBlockTitle/index.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import React, { useRef, useEffect, useState } from 'react'; -import useFieldType from '../../../useFieldType'; - -import './index.scss'; - -const baseClass = 'editable-block-title'; - -const EditableBlockTitle: React.FC<{ path: string }> = (props) => { - const { path } = props; - const inputRef = useRef(null); - const inputCloneRef = useRef(null); - const [inputWidth, setInputWidth] = useState(0); - - const { - value, - setValue, - } = useFieldType({ - path, - }); - - useEffect(() => { - setInputWidth(inputCloneRef.current.offsetWidth + 5); - }, [value]); - - const onKeyDown = (e) => { - const blurKeys = [13, 27]; - if (blurKeys.indexOf(e.keyCode) !== -1) inputRef.current.blur(); - }; - - return ( - -
- -
- - {value || 'Untitled'} - -
- ); -}; - -export default EditableBlockTitle; diff --git a/src/admin/components/forms/DraggableSection/SectionTitle/index.scss b/src/admin/components/forms/DraggableSection/SectionTitle/index.scss index 077b41db32..bc51b83eb8 100644 --- a/src/admin/components/forms/DraggableSection/SectionTitle/index.scss +++ b/src/admin/components/forms/DraggableSection/SectionTitle/index.scss @@ -3,4 +3,31 @@ .section-title { display: flex; align-items: center; + width: 100%; + + &__input { + width: 100%; + color: $color-dark-gray; + background-color: transparent; + font-family: $font-body; + font-weight: 600; + font-size: base(.75); + padding: base(.1) base(.2); + margin-left: base(.5); + margin-right: base(.5); + border: none; + + &:hover { + box-shadow: inset 0px -2px 0px -1px $color-light-gray; + } + + &:hover, + &:focus { + outline: 0; + } + + &:focus { + box-shadow: none; + } + } } diff --git a/src/admin/components/forms/DraggableSection/SectionTitle/index.tsx b/src/admin/components/forms/DraggableSection/SectionTitle/index.tsx index a08a5656b9..61e8fc6f2d 100644 --- a/src/admin/components/forms/DraggableSection/SectionTitle/index.tsx +++ b/src/admin/components/forms/DraggableSection/SectionTitle/index.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import EditableBlockTitle from './EditableBlockTitle'; +import useFieldType from '../../useFieldType'; import Pill from '../../../elements/Pill'; import { Props } from './types'; @@ -8,7 +8,9 @@ import './index.scss'; const baseClass = 'section-title'; const SectionTitle: React.FC = (props) => { - const { label, ...remainingProps } = props; + const { label, path, readOnly } = props; + + const { value, setValue } = useFieldType({ path }); const classes = [ baseClass, @@ -17,7 +19,17 @@ const SectionTitle: React.FC = (props) => { return (
{label} - + +
); };