@@ -45,6 +45,7 @@ export class IconSelectBox extends Disposable {
45
45
46
46
protected inputBox : InputBox | undefined ;
47
47
private scrollableElement : DomScrollableElement | undefined ;
48
+ private iconsContainer : HTMLElement | undefined ;
48
49
private iconIdElement : HighlightedLabel | undefined ;
49
50
private readonly iconContainerWidth = 36 ;
50
51
private readonly iconContainerHeight = 36 ;
@@ -70,8 +71,7 @@ export class IconSelectBox extends Disposable {
70
71
inputBoxStyles : this . options . inputBoxStyles ,
71
72
} ) ) ;
72
73
73
- const iconsContainer = dom . $ ( '.icon-select-icons-container' , { id : `${ this . domId } _icons` } ) ;
74
- iconsContainer . style . paddingRight = '10px' ;
74
+ const iconsContainer = this . iconsContainer = dom . $ ( '.icon-select-icons-container' , { id : `${ this . domId } _icons` } ) ;
75
75
iconsContainer . role = 'listbox' ;
76
76
iconsContainer . tabIndex = 0 ;
77
77
this . scrollableElement = disposables . add ( new DomScrollableElement ( iconsContainer , {
@@ -218,16 +218,22 @@ export class IconSelectBox extends Disposable {
218
218
this . domNode . style . width = `${ dimension . width } px` ;
219
219
this . domNode . style . height = `${ dimension . height } px` ;
220
220
221
- const iconsContainerWidth = dimension . width - 40 ;
221
+ const iconsContainerWidth = dimension . width - 30 ;
222
222
this . numberOfElementsPerRow = Math . floor ( iconsContainerWidth / this . iconContainerWidth ) ;
223
223
if ( this . numberOfElementsPerRow === 0 ) {
224
224
throw new Error ( 'Insufficient width' ) ;
225
225
}
226
226
227
227
const extraSpace = iconsContainerWidth % this . iconContainerWidth ;
228
- const margin = Math . floor ( extraSpace / this . numberOfElementsPerRow ) ;
228
+ const iconElementMargin = Math . floor ( extraSpace / this . numberOfElementsPerRow ) ;
229
229
for ( const { element } of this . renderedIcons ) {
230
- element . style . marginRight = `${ margin } px` ;
230
+ element . style . marginRight = `${ iconElementMargin } px` ;
231
+ }
232
+
233
+ const containerPadding = extraSpace % this . numberOfElementsPerRow ;
234
+ if ( this . iconsContainer ) {
235
+ this . iconsContainer . style . paddingLeft = `${ Math . floor ( containerPadding / 2 ) } px` ;
236
+ this . iconsContainer . style . paddingRight = `${ Math . ceil ( containerPadding / 2 ) } px` ;
231
237
}
232
238
233
239
if ( this . scrollableElement ) {
0 commit comments