Skip to content

Commit

Permalink
🐛 Remove ellipsis hint in cells
Browse files Browse the repository at this point in the history
As the method to detect content overflow seems too unreliable.

Fixes #33
  • Loading branch information
abe33 committed Mar 24, 2016
1 parent 0533a96 commit 7464c73
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
4 changes: 0 additions & 4 deletions lib/table-cell-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ class TableCellElement extends HTMLElement
classes = ['tablr-cell']
classes.push 'active' if @tableElement.isCursorCell([row, column])
classes.push 'selected' if @tableElement.isSelectedCell([row, column])
classes.push 'ellipsis' if @classList.contains('ellipsis') and @isSameCell(cell, column, row)
classes

checkEllipsis: ->
@classList.toggle('ellipsis', @scrollHeight > @clientHeight or @scrollWidth > @clientWidth)

isSameCell: (cell, column, row) ->
cell.value is @lastValue and column is @lastColumn and row is @lastRow

Expand Down
11 changes: 5 additions & 6 deletions lib/table-element.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,8 @@ class TableElement extends HTMLElement

checkEllipsisDisplay: ->
@cancelEllipsisDisplay()
if @getScreenCellAtPosition(@tableEditor.getCursorPosition())?.classList.contains('ellipsis')
@scheduleEllipsisDisplay()
cell = @getScreenCellAtPosition(@tableEditor.getCursorPosition())
@scheduleEllipsisDisplay() if cell? and @contentOverflow(cell)

cancelEllipsisDisplay: ->
clearTimeout(@ellipsisTimeout) if @ellipsisTimeout?
Expand All @@ -694,6 +694,9 @@ class TableElement extends HTMLElement
scheduleEllipsisDisplay: ->
@ellipsisTimeout = setTimeout((=> @displayEllipsis()), 500)

contentOverflow: (cell) ->
cell.scrollHeight > cell.clientHeight or cell.scrollWidth > cell.clientWidth

displayEllipsis: ->
delete @ellipsisTimeout

Expand Down Expand Up @@ -1298,9 +1301,6 @@ class TableElement extends HTMLElement
@update()
@updateRequested = false

requestEllipsisCheck: ->
requestAnimationFrame => cell.checkEllipsis() for key,cell of @cells

markDirtyCell: (position) ->
@dirtyPositions ?= []
@dirtyPositions[position.row] ?= []
Expand Down Expand Up @@ -1361,7 +1361,6 @@ class TableElement extends HTMLElement
@dirtyPositions = null
@dirtyColumns = null
@wholeTableIsDirty = false
@requestEllipsisCheck()

# We never rendered anything
unless @firstRenderedRow?
Expand Down
10 changes: 0 additions & 10 deletions spec/table-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ isVisible = (node) ->
node.offsetHeight? and
node.offsetHeight isnt 0

# The real implementation use a requestAnimationFrame to ensure that there is
# no forced layout update of the DOM when evaluating the size of the cell's
# content. However, in tests, this lead to nasty side effects as we mock the
# requestAnimationFrame method.
TableElement::requestEllipsisCheck = ->
cell.checkEllipsis() for key,cell of @cells

describe 'tableElement', ->
[tableElement, tableShadowRoot, tableEditor, nextAnimationFrame, noAnimationFrame, requestAnimationFrameSafe, styleNode, row, cells, jasmineContent] = []

Expand Down Expand Up @@ -244,9 +237,6 @@ describe 'tableElement', ->
tableEditor.setValueAtPosition([0,0], "some really long text")
nextAnimationFrame()

it 'adds an ellipsis class to the cell', ->
expect(tableElement.getScreenCellAtPosition([0,0]).classList.contains('ellipsis')).toBeTruthy()

it 'sets the proper width and height on the table rows container', ->
bodyContent = tableShadowRoot.querySelector('.tablr-rows-wrapper')

Expand Down

0 comments on commit 7464c73

Please sign in to comment.