mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 20:54:43 +00:00
use textarea.innerInsert for selection-aware text insertion
Both insertText() and handleKeydown() were manually concatenating text to the textarea value, ignoring the current selection range. This uses the existing innerInsert() method which correctly handles full, partial, and no-selection states — matching the Input element behavior.
This commit is contained in:
@@ -3113,9 +3113,7 @@ pub fn handleKeydown(self: *Page, target: *Node, event: *Event) !void {
|
|||||||
else return
|
else return
|
||||||
;
|
;
|
||||||
// zig fmt: on
|
// zig fmt: on
|
||||||
const current_value = textarea.getValue();
|
return textarea.innerInsert(append, self);
|
||||||
const new_value = try std.mem.concat(self.arena, u8, &.{ current_value, append });
|
|
||||||
return textarea.setValue(new_value, self);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3200,13 +3198,11 @@ pub fn insertText(self: *Page, v: []const u8) !void {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try input.innerInsert(v, self);
|
return input.innerInsert(v, self);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (html_element.is(Element.Html.TextArea)) |textarea| {
|
if (html_element.is(Element.Html.TextArea)) |textarea| {
|
||||||
const current_value = textarea.getValue();
|
return textarea.innerInsert(v, self);
|
||||||
const new_value = try std.mem.concat(self.arena, u8, &.{ current_value, v });
|
|
||||||
return textarea.setValue(new_value, self);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user