Skip to content
Permalink
Browse files
Textarea placeholder text does not disappear when inserting text with…
…out a user gesture

Textarea placeholder text does not disappear when inserting text without a user gesture
https://bugs.webkit.org/show_bug.cgi?id=248526

Reviewed by Aditya Keerthi.

This patch is to align Webkit with Gecko / Firefox and Blink / Chromium.

Merge - https://src.chromium.org/viewvc/blink?view=revision&revision=195023

This patch is adding add condition for "subtreeHasChanged" function to update
placeholder visibility after the text is insert via execCommand / JavaScript
without user interaction.

* Source/WebCore/html/HTMLTextareaElement.cpp:
(HTMLTextAreaElement::subtreeHasChanged): Add logic to update Placeholder Visibility
* LayoutTests/fast/forms/textarea/textarea-placeholder-visisbility-3.html: Add Test Case
* LayoutTests/fast/forms/textarea/textarea-placeholder-visisbility-3-expected.html: Add Test Case Expectation

Canonical link: https://commits.webkit.org/257210@main
  • Loading branch information
Ahmad-S792 authored and Ahmad Saleem committed Dec 1, 2022
1 parent 0dca9d9 commit ffe47a6f01ddccf0a295321b0b5270f1fb93db1c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p id="description">Focus field with a placeholder, then type.</p>
<div>
<textarea id=i1>Text</textarea>
</div>
<script>
var i1 = document.getElementById('i1');
i1.focus();
i1.setSelectionRange(4, 4);
</script>
</body>
</html>
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<p id="description">Focus field with a placeholder, then type.</p>
<div>
<textarea id=i1 placeholder="Placeholder"></textarea>
</div>
<script>
var i1 = document.getElementById('i1');
i1.focus();
document.execCommand("InsertText", false, "Text");
</script>
</body>
</html>
@@ -291,6 +291,7 @@ void HTMLTextAreaElement::subtreeHasChanged()
{
setFormControlValueMatchesRenderer(false);
updateValidity();
updatePlaceholderVisibility();

if (!focused())
return;

0 comments on commit ffe47a6

Please sign in to comment.