Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Fixed an autogrow issue that occurs when element is being shown second t... #108

Merged
merged 1 commit into from
Jan 13, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 20 additions & 23 deletions src/components/inputs/inputview.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module.exports = class KDInputView extends KDView
@validationNotifications = {}
@valid = yes
@inputCallback = null
@previousHeight= null
@setName options.name
@setLabel()
@setCallback()
Expand Down Expand Up @@ -318,9 +319,9 @@ module.exports = class KDInputView extends KDView
for rule in @ruleChain
@validationResults[rule] = null


setValidationResult:(rule, err, showNotification=yes)->

if err
@validationResults[rule] = err
@showValidationError err if @getOptions().validate.notifications and showNotification
Expand Down Expand Up @@ -466,35 +467,31 @@ module.exports = class KDInputView extends KDView
@on 'input', (event) => KD.utils.defer => @resize event


resize: do ->

previousHeight = null

(event) ->
resize: (event) ->

return unless @_clone
return unless @_clone

@_clone.appendTo 'body' unless document.body.contains @_clone[0]
val = @getElement().value.replace(/\n/g,'\n ')
safeValue = Encoder.XSSEncode val
@_clone.html safeValue
@_clone.appendTo 'body' unless document.body.contains @_clone[0]
val = @getElement().value.replace(/\n/g,'\n ')
safeValue = Encoder.XSSEncode val
@_clone.html safeValue

height = @_clone.height()
height = @_clone.height()

getValue = (rule) => parseInt @_clone.css(rule), 10
getValue = (rule) => parseInt @_clone.css(rule), 10

if @$().css('boxSizing') is 'border-box'
padding = getValue('paddingTop') + getValue('paddingBottom')
border = getValue('borderTopWidth') + getValue('borderBottomWidth')
height = height + border + padding
if @$().css('boxSizing') is 'border-box'
padding = getValue('paddingTop') + getValue('paddingBottom')
border = getValue('borderTopWidth') + getValue('borderBottomWidth')
height = height + border + padding

newHeight = if @initialHeight then Math.max @initialHeight, height else height
newHeight = if @initialHeight then Math.max @initialHeight, height else height

if previousHeight isnt newHeight
@setHeight newHeight
@emit 'InputHeightChanged'
if @previousHeight isnt newHeight
@setHeight newHeight
@emit 'InputHeightChanged'

previousHeight = newHeight
@previousHeight = newHeight


enableTabKey:-> @inputTabKeyEnabled = yes
Expand Down