From 3fd4b17b801a4a4b0c431e49a0307fe14687cd5c Mon Sep 17 00:00:00 2001
From: francois-unity <105223066+francois-unity@users.noreply.github.com>
Date: Tue, 29 Sep 2026 10:17:52 -0400
Subject: [PATCH] elements/div: add an aria_url passthrough
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Lets an element publish the URL it links to as the AccessKit `url`
property, which is what a web page exposes for an ``. Like the
other `aria_*` passthroughs it only describes the element: opening the
URL stays with the element’s own click handler.
---
crates/gpui/src/elements/div.rs | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/crates/gpui/src/elements/div.rs b/crates/gpui/src/elements/div.rs
index f16f4bad523..4abbc1e65dd 100644
--- a/crates/gpui/src/elements/div.rs
+++ b/crates/gpui/src/elements/div.rs
@@ -1624,6 +1624,14 @@ pub trait StatefulInteractiveElement: InteractiveElement {
self
}
+ /// Set the URL this element links to (maps to the AccessKit `url`
+ /// property), the target a web page exposes for an ``. This only
+ /// describes the element to assistive technology; it does not open the URL.
+ fn aria_url(mut self, url: impl Into) -> Self {
+ self.interactivity().aria.url = Some(url.into());
+ self
+ }
+
/// Set the minimum numeric value for this element.
fn aria_min_numeric_value(mut self, value: f64) -> Self {
self.interactivity().aria.min_numeric_value = Some(value);
@@ -2463,6 +2471,7 @@ pub(crate) struct AriaProperties {
pub(crate) numeric_value_step: Option,
pub(crate) value: Option,
pub(crate) placeholder: Option,
+ pub(crate) url: Option,
pub(crate) orientation: Option,
pub(crate) level: Option,
pub(crate) position_in_set: Option,
@@ -4022,6 +4031,9 @@ impl Interactivity {
if let Some(placeholder) = &self.aria.placeholder {
node.set_placeholder(placeholder.to_string());
}
+ if let Some(url) = &self.aria.url {
+ node.set_url(url.to_string());
+ }
if let Some(orientation) = self.aria.orientation {
node.set_orientation(orientation);
}
@@ -5479,6 +5491,16 @@ mod tests {
assert_eq!(node.author_id(), Some("settings.buffer-font-size"));
}
+ #[test]
+ fn test_aria_url_builder_writes_url() {
+ let mut element = div().id("docs-link").aria_url("https://example.com/docs");
+ let mut node = accesskit::Node::new(accesskit::Role::Link);
+
+ element.interactivity().write_a11y_info(&mut node);
+
+ assert_eq!(node.url(), Some("https://example.com/docs"));
+ }
+
#[test]
fn test_write_a11y_info_string_and_numeric_properties() {
let mut interactivity = Interactivity::default();