move the emptyContentEditable hack to componentWillUnmount
							parent
							
								
									98be71680d
								
							
						
					
					
						commit
						f613f27ee3
					
				@ -1,29 +1,31 @@
 | 
			
		||||
import React from 'react';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
interface Props {
 | 
			
		||||
    placeholder: string;
 | 
			
		||||
    editable?: boolean;
 | 
			
		||||
    onChange?: any;
 | 
			
		||||
  placeholder: string;
 | 
			
		||||
  editable?: boolean;
 | 
			
		||||
  onChange?: any;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export class SessionIdEditable extends React.PureComponent<Props> {
 | 
			
		||||
  public componentWillUnmount() {
 | 
			
		||||
    //FIXME ugly hack to empty the content editable div used on enter session ID
 | 
			
		||||
    window.Session.emptyContentEditableDivs();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    public render() {
 | 
			
		||||
        const { placeholder, editable, onChange } = this.props;
 | 
			
		||||
  public render() {
 | 
			
		||||
    const { placeholder, editable, onChange } = this.props;
 | 
			
		||||
 | 
			
		||||
        return (
 | 
			
		||||
            <div
 | 
			
		||||
                className="session-id-editable"
 | 
			
		||||
                placeholder={placeholder}
 | 
			
		||||
                contentEditable={editable}
 | 
			
		||||
                onInput={(e: any) => {
 | 
			
		||||
                    if (editable) {
 | 
			
		||||
                        onChange(e);
 | 
			
		||||
                    }
 | 
			
		||||
                }}
 | 
			
		||||
            />
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    return (
 | 
			
		||||
      <div
 | 
			
		||||
        className="session-id-editable"
 | 
			
		||||
        placeholder={placeholder}
 | 
			
		||||
        contentEditable={editable}
 | 
			
		||||
        onInput={(e: any) => {
 | 
			
		||||
          if (editable) {
 | 
			
		||||
            onChange(e);
 | 
			
		||||
          }
 | 
			
		||||
        }}
 | 
			
		||||
      />
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
					Loading…
					
					
				
		Reference in New Issue