Skip to content

Commit d9f314f

Browse files
authored
Do not allow pxToRem function get undifined (#4206)
* Do not allow `pxToRem` function get `undifined` * `TextBox` width fix
1 parent 7f92983 commit d9f314f

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

app/src/lib/shared/Scrollbar.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
3535
$: vert = !horz;
3636
37-
$: paddingTop = pxToRem(padding.top) ?? '0px';
38-
$: paddingBottom = pxToRem(padding.bottom) ?? '0px';
39-
$: paddingRight = pxToRem(padding.right) ?? '0px';
40-
$: paddingLeft = pxToRem(padding.left) ?? '0px';
37+
$: paddingTop = pxToRem(padding.top ?? 0);
38+
$: paddingBottom = pxToRem(padding.bottom ?? 0);
39+
$: paddingRight = pxToRem(padding.right ?? 0);
40+
$: paddingLeft = pxToRem(padding.left ?? 0);
4141
4242
$: wholeHeight = viewport?.scrollHeight ?? 0;
4343
$: wholeWidth = viewport?.scrollWidth ?? 0;

app/src/lib/shared/TextBox.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
class="textbox"
5050
bind:this={element}
5151
class:wide
52-
style:width={pxToRem(width)}
52+
style:width={width ? pxToRem(width) : undefined}
5353
class:wiggle={!isInputValid}
5454
>
5555
{#if label}

app/src/lib/utils/pxToRem.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export function pxToRem(px: number | undefined, base: number = 16) {
2-
if (!px) return;
1+
export function pxToRem(px: number, base: number = 16) {
32
return `${px / base}rem`;
43
}

0 commit comments

Comments
 (0)