Skip to content

Commit 58d5255

Browse files
authored
Merge pull request #4772 from IgniteUI/fix-#4752-7.4.x
fix(input-group): some japanese symbols don't fit the input box
2 parents 19a7512 + 5c7710c commit 58d5255

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

projects/igniteui-angular/src/lib/core/styles/components/input/_input-group-theme.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -566,8 +566,6 @@
566566
display: block;
567567
border: none;
568568
height: rem(32px, map-get($base-scale-size, 'comfortable'));
569-
padding: 0 0 rem(8px, map-get($base-scale-size, 'comfortable'));
570-
border-top: rem(8px, map-get($base-scale-size, 'comfortable')) solid rgba(0, 0, 0, 0);
571569
line-height: 0 !important; /* resets typography styles */
572570
width: 100%;
573571
min-width: 0;
@@ -589,15 +587,11 @@
589587

590588
%form-group-input--cosy {
591589
height: rem(32px, map-get($base-scale-size, 'cosy'));
592-
padding: 0 0 rem(8px, map-get($base-scale-size, 'cosy'));
593-
border-top: rem(8px, map-get($base-scale-size, 'cosy')) solid rgba(0, 0, 0, 0);
594590
}
595591

596592
%form-group-input--compact {
597593
font-size: rem(map-get($base-scale-size, 'compact') - 1px, map-get($base-scale-size, 'compact'));
598594
height: rem(32px, map-get($base-scale-size, 'compact'));
599-
padding: 0 0 rem(8px, map-get($base-scale-size, 'compact'));
600-
border-top: rem(8px, map-get($base-scale-size, 'compact')) solid rgba(0, 0, 0, 0);
601595
}
602596

603597
%chrome-autofill-fix {

projects/igniteui-angular/src/lib/select/select-positioning-strategy.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@ export class SelectPositioningStrategy extends ConnectedPositioningStrategy impl
3737
private deltaX: number;
3838
private itemTextPadding: number;
3939
private itemTextIndent: number;
40-
private inputBorderTop: number;
4140
private listContainerBoundRect: DOMRect;
41+
private itemTextToInputTextDiff: number;
4242

4343
private positionAndScrollBottom(contentElement: HTMLElement, outBoundsAmount: number) {
4444
contentElement.style.top = `${this.viewPort.bottom - this.listContainerBoundRect.height - this.defaultWindowToListOffset}px`;
45-
contentElement.firstElementChild.scrollTop -= outBoundsAmount - (this.inputBorderTop - this.defaultWindowToListOffset);
45+
contentElement.firstElementChild.scrollTop -= outBoundsAmount - (this.defaultWindowToListOffset);
4646
this.deltaY = this.viewPort.bottom - this.listContainerBoundRect.height -
4747
this.defaultWindowToListOffset - (this.select.input.nativeElement.getBoundingClientRect() as DOMRect).top;
4848
}
4949

5050
private positionNoScroll(contentElement: HTMLElement, CURRENT_POSITION_Y: number) {
51-
contentElement.style.top = `${CURRENT_POSITION_Y - this.inputBorderTop}px`;
52-
this.deltaY = CURRENT_POSITION_Y - this.inputBorderTop -
53-
(this.select.input.nativeElement.getBoundingClientRect() as DOMRect).top;
51+
contentElement.style.top = `${CURRENT_POSITION_Y - this.itemTextToInputTextDiff }px`;
52+
this.deltaY = CURRENT_POSITION_Y -
53+
(this.select.input.nativeElement.getBoundingClientRect() as DOMRect).top - this.itemTextToInputTextDiff;
5454
}
5555

5656
private positionAndScrollTop(contentElement: HTMLElement, outBoundsAmount: number) {
5757
contentElement.style.top = `${this.viewPort.top + this.defaultWindowToListOffset}px`;
58-
contentElement.firstElementChild.scrollTop += outBoundsAmount + this.inputBorderTop + this.defaultWindowToListOffset;
58+
contentElement.firstElementChild.scrollTop += outBoundsAmount + this.itemTextToInputTextDiff + this.defaultWindowToListOffset;
5959
this.deltaY = this.viewPort.top + this.defaultWindowToListOffset -
6060
(this.select.input.nativeElement.getBoundingClientRect() as DOMRect).top;
6161
}
@@ -140,6 +140,14 @@ export class SelectPositioningStrategy extends ConnectedPositioningStrategy impl
140140
const itemTopListOffset = itemBoundRect.top - this.listContainerBoundRect.top;
141141
const itemHeight = itemBoundRect.height;
142142

143+
const inputFontSize = window.getComputedStyle(inputElement).fontSize;
144+
const numericInputFontSize = parseInt(inputFontSize.slice(0, inputFontSize.indexOf('p')), 10) || 0;
145+
const itemFontSize = window.getComputedStyle(itemElement).fontSize;
146+
const numericItemFontSize = parseInt(itemFontSize.slice(0, itemFontSize.indexOf('p')), 10) || 0;
147+
const inputTextToInputTop = (inputHeight - numericInputFontSize) / 2;
148+
const itemTextToItemTop = (itemHeight - numericItemFontSize) / 2;
149+
this.itemTextToInputTextDiff = itemTextToItemTop - inputTextToInputTop;
150+
143151
let CURRENT_POSITION_Y = START.Y - itemTopListOffset;
144152
const CURRENT_BOTTOM_Y = CURRENT_POSITION_Y + this.listContainerBoundRect.height;
145153

@@ -155,17 +163,15 @@ export class SelectPositioningStrategy extends ConnectedPositioningStrategy impl
155163
CURRENT_POSITION_Y += START.Y;
156164
}
157165
}
158-
const inputBorderTop = window.getComputedStyle(inputElement).borderTopWidth;
159-
this.inputBorderTop = parseInt(inputBorderTop.slice(0, inputBorderTop.indexOf('p')), 10) || 0;
160166
const itemLeftPadding = window.getComputedStyle(itemElement).paddingLeft;
161167
const itemTextIndent = window.getComputedStyle(itemElement).textIndent;
162-
const numericPadding = parseInt(itemLeftPadding.slice(0, itemLeftPadding.indexOf('p')), 10) || 0;
168+
const numericLeftPadding = parseInt(itemLeftPadding.slice(0, itemLeftPadding.indexOf('p')), 10) || 0;
163169
const numericTextIndent = parseInt(itemTextIndent.slice(0, itemTextIndent.indexOf('r')), 10) || 0;
164-
this.itemTextPadding = numericPadding;
170+
this.itemTextPadding = numericLeftPadding;
165171
this.itemTextIndent = numericTextIndent;
166-
contentElement.style.left += `${START.X - numericPadding - numericTextIndent}px`;
172+
contentElement.style.left += `${START.X - numericLeftPadding - numericTextIndent}px`;
167173
contentElement.style.width = inputRect.width + 24 + 32 + 'px';
168-
this.deltaX = START.X - numericPadding - numericTextIndent;
174+
this.deltaX = START.X - numericLeftPadding - numericTextIndent;
169175
const currentScroll = this.getItemsOutOfView(contentElement, itemHeight)['currentScroll'];
170176
const remainingScroll = this.getItemsOutOfView(contentElement, itemHeight)['remainingScroll'];
171177

0 commit comments

Comments
 (0)