Skip to content

Commit 302e182

Browse files
committed
Fixed bug that sometimes texts disappear in Chrome
1 parent 3ec62a4 commit 302e182

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/__snapshots__/index.spec.tsx.snap

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ exports[`match emoji 1`] = `
6969
</div>
7070
</div>
7171
<textarea
72-
style="background: transparent; margin: 0px; color: transparent;"
72+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
7373
>
7474
Lorem😇 ipsum dolor sit amet👨‍👩‍👧‍👦 Lorem ipsum dolor👍🏽 sit amet Lorem👩‍💻 ipsum dolor sit amet
7575
</textarea>
@@ -293,7 +293,7 @@ exports[`match japanese 1`] = `
293293
</div>
294294
</div>
295295
<textarea
296-
style="background: transparent; margin: 0px; color: transparent;"
296+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
297297
>
298298
あのイーハトーヴォのすきとおった風、夏でも底に冷たさをもつ青いそら、うつくしい森で飾られたモリーオ市、郊外のぎらぎらひかる草の波。
299299
</textarea>
@@ -345,7 +345,7 @@ exports[`match match many 1`] = `
345345
</div>
346346
</div>
347347
<textarea
348-
style="background: transparent; margin: 0px; color: transparent;"
348+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
349349
>
350350
Lorem ipsum dolor sit amet
351351
</textarea>
@@ -375,7 +375,7 @@ exports[`match match one 1`] = `
375375
</div>
376376
</div>
377377
<textarea
378-
style="background: transparent; margin: 0px; color: transparent;"
378+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
379379
>
380380
Lorem ipsum dolor sit amet
381381
</textarea>
@@ -438,7 +438,7 @@ exports[`match multiple matchers 1`] = `
438438
</div>
439439
</div>
440440
<textarea
441-
style="background: transparent; margin: 0px; color: transparent;"
441+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
442442
>
443443
Lorem ipsum dolor sit amet
444444
</textarea>
@@ -468,7 +468,7 @@ exports[`style textarea background 1`] = `
468468
</div>
469469
</div>
470470
<textarea
471-
style="background: transparent; margin: 0px; color: transparent;"
471+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
472472
>
473473
Lorem ipsum dolor sit amet
474474
</textarea>
@@ -498,7 +498,7 @@ exports[`style textarea background-color 1`] = `
498498
</div>
499499
</div>
500500
<textarea
501-
style="background: transparent; margin: 0px; color: transparent;"
501+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
502502
>
503503
Lorem ipsum dolor sit amet
504504
</textarea>
@@ -528,7 +528,7 @@ exports[`style textarea border 1`] = `
528528
</div>
529529
</div>
530530
<textarea
531-
style="border: 1px solid blue; background: transparent; margin: 0px; color: transparent;"
531+
style="border: 1px solid blue; background: transparent; margin: 0px; position: absolute; color: transparent;"
532532
>
533533
Lorem ipsum dolor sit amet
534534
</textarea>
@@ -558,7 +558,7 @@ exports[`style textarea border-color 1`] = `
558558
</div>
559559
</div>
560560
<textarea
561-
style="border-color: blue; background: transparent; margin: 0px; color: transparent;"
561+
style="border-color: blue; background: transparent; margin: 0px; position: absolute; color: transparent;"
562562
>
563563
Lorem ipsum dolor sit amet
564564
</textarea>
@@ -588,7 +588,7 @@ exports[`style textarea caret-color 1`] = `
588588
</div>
589589
</div>
590590
<textarea
591-
style="caret-color: blue; background: transparent; margin: 0px; color: transparent;"
591+
style="caret-color: blue; background: transparent; margin: 0px; position: absolute; color: transparent;"
592592
>
593593
Lorem ipsum dolor sit amet
594594
</textarea>
@@ -618,7 +618,7 @@ exports[`style textarea color 1`] = `
618618
</div>
619619
</div>
620620
<textarea
621-
style="color: transparent; background: transparent; margin: 0px; caret-color: blue;"
621+
style="color: transparent; background: transparent; margin: 0px; position: absolute; caret-color: blue;"
622622
>
623623
Lorem ipsum dolor sit amet
624624
</textarea>
@@ -648,7 +648,7 @@ exports[`style textarea width & height 1`] = `
648648
</div>
649649
</div>
650650
<textarea
651-
style="width: 123px; height: 456px; background: transparent; margin: 0px; color: transparent;"
651+
style="width: 123px; height: 456px; background: transparent; margin: 0px; position: absolute; color: transparent;"
652652
>
653653
Lorem ipsum dolor sit amet
654654
</textarea>
@@ -678,7 +678,7 @@ exports[`style value background 1`] = `
678678
</div>
679679
</div>
680680
<textarea
681-
style="background: transparent; margin: 0px; color: transparent;"
681+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
682682
>
683683
Lorem ipsum dolor sit amet
684684
</textarea>
@@ -708,7 +708,7 @@ exports[`style value border 1`] = `
708708
</div>
709709
</div>
710710
<textarea
711-
style="background: transparent; margin: 0px; color: transparent;"
711+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
712712
>
713713
Lorem ipsum dolor sit amet
714714
</textarea>
@@ -738,7 +738,7 @@ exports[`style value color 1`] = `
738738
</div>
739739
</div>
740740
<textarea
741-
style="background: transparent; margin: 0px; color: transparent;"
741+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
742742
>
743743
Lorem ipsum dolor sit amet
744744
</textarea>
@@ -768,7 +768,7 @@ exports[`style value decoration 1`] = `
768768
</div>
769769
</div>
770770
<textarea
771-
style="background: transparent; margin: 0px; color: transparent;"
771+
style="background: transparent; margin: 0px; position: absolute; color: transparent;"
772772
>
773773
Lorem ipsum dolor sit amet
774774
</textarea>

src/textarea.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,13 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
204204
...props,
205205
ref: useMemo(() => mergeRefs([ref, propRef]), [ref, propRef]),
206206
style: useMemo(
207-
() => ({ ...style, background: "transparent", margin: 0 }),
207+
() => ({
208+
...style,
209+
background: "transparent",
210+
margin: 0,
211+
// Fixed bug that sometimes texts disappear in Chrome for unknown reason
212+
position: "absolute",
213+
}),
208214
[style]
209215
),
210216
onScroll: useCallback(

0 commit comments

Comments
 (0)