Skip to content

Commit

Permalink
remove classname
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Oct 29, 2020
1 parent 43104b5 commit 44a6cac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ export const TimelineTitleAndDescription = React.memo<TimelineTitleAndDescriptio
<EuiFormRow label={TIMELINE_TITLE}>
<Name
autoFocus={true}
className="timeline-modal-title"
disableTooltip={true}
disableAutoSave={true}
disabled={isSaving}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
EuiToolTip,
EuiTextArea,
} from '@elastic/eui';
import React, { useCallback, useEffect, useMemo } from 'react';
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import uuid from 'uuid';
import styled from 'styled-components';
import { useDispatch } from 'react-redux';
Expand Down Expand Up @@ -200,7 +200,6 @@ Description.displayName = 'Description';

interface NameProps {
autoFocus?: boolean;
className?: string;
disableAutoSave?: boolean;
disableTooltip?: boolean;
disabled?: boolean;
Expand All @@ -215,7 +214,6 @@ interface NameProps {
export const Name = React.memo<NameProps>(
({
autoFocus = false,
className = TIMELINE_TITLE_CLASSNAME,
disableAutoSave = false,
disableTooltip = false,
disabled = false,
Expand All @@ -226,23 +224,18 @@ export const Name = React.memo<NameProps>(
width,
marginRight,
}) => {
const timelineNameRef = useRef<HTMLInputElement>(null);

const handleChange = useCallback(
(e) => updateTitle({ id: timelineId, title: e.target.value, disableAutoSave }),
[timelineId, updateTitle, disableAutoSave]
);

useEffect(() => {
const focusInput = () => {
const elements = document.querySelector<HTMLElement>(`.${className}`);

if (elements != null) {
elements.focus();
}
};
if (autoFocus) {
focusInput();
if (autoFocus && timelineNameRef && timelineNameRef.current) {
timelineNameRef.current.focus();
}
}, [autoFocus, className]);
}, [autoFocus]);

const nameField = useMemo(
() => (
Expand All @@ -258,10 +251,10 @@ export const Name = React.memo<NameProps>(
value={title}
width={width}
marginRight={marginRight}
className={className}
inputRef={timelineNameRef}
/>
),
[handleChange, marginRight, timelineType, title, width, className, disabled]
[handleChange, marginRight, timelineType, title, width, disabled]
);

return (
Expand Down

0 comments on commit 44a6cac

Please sign in to comment.