diff --git a/addon/components/justa-table.js b/addon/components/justa-table.js index 8ab3589..582ffb1 100644 --- a/addon/components/justa-table.js +++ b/addon/components/justa-table.js @@ -19,6 +19,8 @@ const { inject: { service } } = Ember; +const HORIZONTAL_SCROLLBAR_HEIGHT = 15; + export default Component.extend(InViewportMixin, { layout, classNames: ['justa-table'], @@ -122,20 +124,28 @@ export default Component.extend(InViewportMixin, { let actualHeight = this.$('.table-columns table').outerHeight(); let totalHeight = actualHeight === 0 ? requestedHeight : Math.min(requestedHeight, actualHeight); let isWindows = this.get('isWindows'); + let shouldAddHeightBuffer = isWindows && this._hasHorizontalScroll(); - if (isWindows) { - totalHeight = totalHeight + 16; + if (shouldAddHeightBuffer) { + totalHeight = totalHeight + HORIZONTAL_SCROLLBAR_HEIGHT; } this.$().height(totalHeight); - // windows does not respect the height set, so it needs a 2px buffer - this.$('.table-columns').height(isWindows ? totalHeight + 2 : totalHeight); + // windows does not respect the height set, so it needs a 2px buffer if horizontal scrollbar + this.$('.table-columns').height(shouldAddHeightBuffer ? totalHeight + 2 : totalHeight); run.next(() => { this.set('containerSize', totalHeight); }); }, + _hasHorizontalScroll() { + let tableWidth = this.$('.standard-table-columns-wrapper table').outerWidth(); + let containerWidth = this.$('.standard-table-columns-wrapper .table-columns').outerWidth(); + + return tableWidth > containerWidth; + }, + /** Windows machines need slightly different css for scrollable containers. Returns a boolean that is applied as a classNameBinding to the justa-table