         @props.actions.save_scroll_state(node.scrollTop, node.scrollHeight, node.offsetHeight)
         e.preventDefault()
 
+    set_preview_state: ->
+        if @refs.log_container?
+            @setState(preview:@props.input)
+
+    componentWillMount: ->
+        @set_preview_state = underscore.debounce(@set_preview_state, 500)
+
     componentDidMount: ->
+        #console.log(@props.edited_input)
+        #@props.actions.set_edited_input('')
         @scroll_to_position()
 
     componentWillReceiveProps: (next) ->
-        if @props.messages != next.messages and @is_at_bottom()
+        #console.log('chatroom component will receive props is called')
+        if (@props.messages != next.messages or @props.input != next.input) and @is_at_bottom()
             @_use_saved_position = false
 
+    #componentWillUpdate: ->
+        #console.log('chatroom component will update is called')
+
     componentDidUpdate: ->
+        #console.log(@props.edited_input)
+        #console.log('chatroom component did update is called')
         if not @_use_saved_position
             @scroll_to_bottom()
 

        is_next_sender : rtypes.bool
        actions        : rtypes.object
        show_heads     : rtypes.bool

    getInitialState: ->
        edited_message  : @newest_content()
        new_changes     : false

    componentWillReceiveProps: (newProps) ->
        if @state.history_size != @props.message.get('history').size
            @setState(history_size:@props.message.get('history').size)
        changes = false

        margin       : "0"
        padding      : "4px 7px 4px 7px"
        marginTop    : "5px"

    preview_style:
        background   : '#f5f5f5'
        fontSize     : '14px'
        borderRadius : '10px 10px 10px 10px'
        borderColor  : '#000'
        paddingBottom: '20px'

    is_at_bottom: ->
        # 20 for covering margin of bottom message
