1- /* eslint react/destructuring-assignment: "off" */
21/* eslint class-methods-use-this: "off" */
3- /* eslint no-param-reassign: "off" */
42import {
53 BoundedAxisRange ,
64 Coordinate ,
@@ -69,15 +67,15 @@ export class IrisGridRenderer extends GridRenderer {
6967
7068 protected dataBarCellRenderer = new IrisGridDataBarCellRenderer ( ) ;
7169
72- getSortIcon ( sort : dh . Sort | null ) : Path2D | null {
70+ getSortIcon ( sort : dh . Sort | null , size : number ) : Path2D | null {
7371 if ( ! sort ) {
7472 return null ;
7573 }
7674 if ( sort . direction === TableUtils . sortDirection . ascending ) {
77- return getIcon ( ICON_NAMES . SORT_UP ) ;
75+ return getIcon ( ICON_NAMES . SORT_UP , size ) ;
7876 }
7977 if ( sort . direction === TableUtils . sortDirection . descending ) {
80- return getIcon ( ICON_NAMES . SORT_DOWN ) ;
78+ return getIcon ( ICON_NAMES . SORT_DOWN , size ) ;
8179 }
8280 return null ;
8381 }
@@ -135,7 +133,7 @@ export class IrisGridRenderer extends GridRenderer {
135133 mouseX : Coordinate | null ;
136134 mouseY : Coordinate | null ;
137135 metrics : GridMetrics | undefined ;
138- theme : GridThemeType ;
136+ theme : IrisGridThemeType ;
139137 } ) : {
140138 left : Coordinate | null ;
141139 top : Coordinate | null ;
@@ -173,6 +171,7 @@ export class IrisGridRenderer extends GridRenderer {
173171 cellHorizontalPadding,
174172 overflowButtonColor,
175173 overflowButtonHoverColor,
174+ iconSize,
176175 } = theme ;
177176
178177 context . save ( ) ;
@@ -191,9 +190,12 @@ export class IrisGridRenderer extends GridRenderer {
191190 } else if ( overflowButtonColor != null ) {
192191 context . fillStyle = overflowButtonColor ;
193192 }
194- const icon = getIcon ( ICON_NAMES . CELL_OVERFLOW ) ;
195- if ( buttonLeft != null && buttonTop != null ) {
196- context . translate ( buttonLeft + cellHorizontalPadding , buttonTop + 2 ) ;
193+ const icon = getIcon ( ICON_NAMES . CELL_OVERFLOW , iconSize ) ;
194+ if ( buttonLeft != null && buttonTop != null && buttonHeight != null ) {
195+ context . translate (
196+ buttonLeft + cellHorizontalPadding ,
197+ buttonTop + ( buttonHeight - iconSize ) / 2
198+ ) ;
197199 }
198200 context . fill ( icon ) ;
199201
@@ -470,7 +472,8 @@ export class IrisGridRenderer extends GridRenderer {
470472 fontWidths,
471473 } = metrics ;
472474
473- const { headerHorizontalPadding } = theme ;
475+ const { headerHorizontalPadding, iconSize : themeIconSize } = theme ;
476+ const iconSize = Math . round ( themeIconSize * 0.75 ) ; // The vsTriangle icons are a bit bigger than we want
474477 const columnWidth = getOrThrow ( allColumnWidths , index , 0 ) ;
475478 const columnX = getOrThrow ( allColumnXs , index ) + gridX ;
476479 const modelColumn = modelColumns . get ( index ) ;
@@ -491,7 +494,7 @@ export class IrisGridRenderer extends GridRenderer {
491494 return ;
492495 }
493496
494- const icon = this . getSortIcon ( sort ) ;
497+ const icon = this . getSortIcon ( sort , iconSize ) ;
495498 if ( ! icon ) {
496499 return ;
497500 }
@@ -506,14 +509,14 @@ export class IrisGridRenderer extends GridRenderer {
506509 const textWidth = text . length * fontWidth ;
507510 const textRight = gridX + columnX + textWidth + headerHorizontalPadding ;
508511 let { maxX } = bounds ;
509- maxX -= headerHorizontalPadding ;
510- const defaultX =
511- gridX + columnX + columnWidth - headerHorizontalPadding - 1 ;
512+ maxX -= headerHorizontalPadding ; // Right visible edge of the headers
513+ // Right edge of the column. The icon has its own horizontal padding
514+ const defaultX = gridX + columnX + columnWidth - iconSize ;
512515
516+ // If the text is partially off the screen, put the icon to the right of the text
517+ // else put it at the right edge of the column/grid (whichever is smaller)
513518 const x = textRight > maxX ? textRight + 1 : Math . min ( maxX , defaultX ) ;
514- const yOffset =
515- sort . direction === TableUtils . sortDirection . ascending ? - 6 : - 12 ;
516- const y = columnHeaderHeight * 0.5 + yOffset ;
519+ const y = ( columnHeaderHeight - iconSize ) * 0.5 ;
517520
518521 context . save ( ) ;
519522
0 commit comments