@@ -36,7 +36,7 @@ const MEDIA_QUERY_ANY_HOVER_NONE: &'static str = "(any-hover: none)";
36
36
const MEDIA_QUERY_ANY_POINTER_NONE_OR_COARSE : & ' static str =
37
37
"(any-pointer: none) or (any-pointer: coarse)" ;
38
38
39
- /// Trigger options for [TooltipProps::trigger_on_focus].
39
+ /// Trigger options for [` TooltipProps::trigger_on_focus` ].
40
40
///
41
41
/// This allows tooltips to be selectively enabled on focus, depending on the
42
42
/// result of which [Interaction Media Features][0] the user's device supports.
@@ -63,8 +63,8 @@ pub enum TooltipFocusTrigger {
63
63
/// devices connected (`hover: none`).
64
64
///
65
65
/// If the primary pointing device supports hovering (eg: mouse, trackpad,
66
- /// trackball, smart pen, Wiimote), the tooltip will not be shown when
67
- /// the element has focus.
66
+ /// trackball, smart pen, Wiimote, Leap Motion Controller ), the tooltip will
67
+ /// not be shown when the element has focus.
68
68
///
69
69
/// Figuring out what the "primary" pointing device actually is
70
70
/// [can be complicated to answer for some devices][0]. They generally err
@@ -74,21 +74,21 @@ pub enum TooltipFocusTrigger {
74
74
///
75
75
/// Both [Chromium][2] and [Firefox][3] on Windows erroneously report
76
76
/// touch-only devices as having an ordinary mouse with hover capabilities
77
- /// if the device lacks an auto-rotation sensor (as is the case for
78
- /// non-tablet devices like external touchscreen monitors and all-in-one
79
- /// PCs).
77
+ /// if the device lacks an auto-rotation sensor (even if disabled), which is
78
+ /// generally the case for non-tablet devices like external touchscreen
79
+ /// monitors and all-in-one PCs).
80
80
///
81
81
/// [Some Android devices also erroneously report `hover: hover`][4], even
82
- /// when they have a touch screen.
82
+ /// when they only have a touch screen.
83
83
///
84
84
/// For someone who primarily uses a keyboard to interact with their
85
- /// computer, but has a mouse plugged in (which could a laptop with a
86
- /// built-in trackpad, or a virtual device), their browser will still report
87
- /// a primary pointing device which is "hover capable", even when they have
88
- /// no way to hover.
85
+ /// computer, but has a mouse plugged in (eg: a laptop with a built-in
86
+ /// trackpad, or a virtual device), their browser will still report a
87
+ /// primary pointing device which is "hover capable", even when they have no
88
+ /// way to hover.
89
89
///
90
90
/// These implementation problems and shortfalls make the `hover: none`
91
- /// media query unreliable.
91
+ /// media query unreliable, and an unreliable indicator of user preferences .
92
92
///
93
93
/// [0]: https://firefox-source-docs.mozilla.org/widget/windows/windows-pointing-device/index.html#selection-of-the-primary-pointing-device
94
94
/// [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1851244
@@ -105,13 +105,13 @@ pub enum TooltipFocusTrigger {
105
105
/// phone with a touch screen or basic stylus), this is the same as
106
106
/// [`TooltipFocusTrigger::IfHoverNone`].
107
107
///
108
- /// Unfortunately, [there is no way to detect if not *all* pointer devices support hovering][1].
109
- ///
110
108
/// For a device with *both* hovering and non-hovering pointing device(s)
111
109
/// (eg: a laptop with a trackpad and touchscreen, or a tablet with both pen
112
110
/// and touch input), this option will never show will never show the
113
111
/// tooltip on focus.
114
112
///
113
+ /// Unfortunately, [there is no way to detect if not *all* pointer devices support hovering][1].
114
+ ///
115
115
/// Most desktop browsers will *always* report the presence of an ordinary
116
116
/// (hover-capable) mouse, even if none is attached. This can be caused by:
117
117
///
@@ -130,7 +130,7 @@ pub enum TooltipFocusTrigger {
130
130
/// interact with their computer.
131
131
///
132
132
/// These implementation problems and shortfalls make the `any-hover: none`
133
- /// media query unreliable.
133
+ /// media query an unreliable indicator of user preferences .
134
134
///
135
135
/// [1]: https://github.com/w3c/csswg-drafts/issues/5462
136
136
/// [2]: https://issues.chromium.org/issues/366055333
@@ -140,28 +140,38 @@ pub enum TooltipFocusTrigger {
140
140
/// Trigger showing tooltips on element focus only if:
141
141
///
142
142
/// * there are no pointer devices present (`any-pointer: none`), **or**,
143
- /// * there are no *coarse* pointer devices present (`any-pointer: coarse`),
144
- /// such as a touchscreen or Wiimote
143
+ /// * there are *coarse* pointer devices present (`any-pointer: coarse`),
144
+ /// such as a touchscreen, Wiimote or Leap Motion Controller
145
145
///
146
146
/// This is a work-around for there being
147
147
/// [no way for a browser to report that not all devices support `hover`][1],
148
148
/// and the complex heuristics required (which all browsers lack) to
149
- /// determine which is the "primary" pointing device.
149
+ /// determine which is the "primary" pointing device on desktop and laptop
150
+ /// computers.
150
151
///
151
- /// The intent is that tooltips will be shown on devices with touchscreens,
152
- /// regardless of whether they have an auto-rotation sensor.
152
+ /// The intent of this mode is that tooltips will be shown on `focus` for
153
+ /// devices with touchscreens, *regardless* of whether they have an
154
+ /// auto-rotation sensor.
153
155
///
154
156
/// The side-effects are:
155
157
///
156
- /// * hovering `coarse` pointer devices (like the Wiimote) will *also* show
157
- /// tooltips on focus, even though they can hover
158
+ /// * hovering `coarse` pointer devices (like the Wiimote and Leap Motion
159
+ /// Controller) will *also* show tooltips on focus, even though they can
160
+ /// hover
161
+ /// * traditional-style laptops with touchscreens (ie: not foldable or
162
+ /// convertible into a tablet) will *also* show tooltips on focus, even
163
+ /// though using the touchscreen as a primary pointing device is very
164
+ /// uncomfortable (because it requires reaching over the keyboard)
158
165
/// * non-hovering `fine` pointer devices (like basic stylus digitisers)
159
166
/// will *not* show tooltips on focus, even though they can't hover
160
167
/// * a user primarily using non-pointer (keyboard) input but with at least
161
- /// one pointing device connected (such as a laptop with built-in
162
- /// trackpad) will never see tooltips
168
+ /// one `fine` pointing device connected (such as a laptop with built-in
169
+ /// trackpad) will never see tooltips on focus
170
+ /// * [Safari doesn't fire `focus` events][2] on components on click or
171
+ /// touch if it does not accept keyboard input (eg: `<a>` and `<button>`)
163
172
///
164
173
/// [1]: https://github.com/w3c/csswg-drafts/issues/5462
174
+ /// [2]: https://webkit.org/b/22261#c68
165
175
IfAnyPointerNoneOrCoarse ,
166
176
167
177
/// Never show the tooltip on element focus.
@@ -249,19 +259,34 @@ pub struct TooltipProps {
249
259
/// or keyboard focus.
250
260
///
251
261
/// This defaults to [`TooltipFocusTrigger::Always`], which always shows the
252
- /// tooltip on input focus. See [`TooltipFocusTrigger`] for other options,
262
+ /// tooltip on input focus. See [`TooltipFocusTrigger`] for other options
263
+ /// which selectively disable this behaviour based on media queries,
253
264
/// and full caveats on each.
254
265
///
255
266
/// This [will not trigger on `disabled` elements][0].
256
267
///
268
+ /// ## Safari/WebKit focus events
269
+ ///
257
270
/// *Unlike* most other web browsers (even on macOS), Safari and other
258
271
/// browsers using the WebKit renderer[^1] do not fire `focus` events for
259
- /// `<a>` or `<button>` elements when clicked or touched,
260
- /// [because clicking a button on macOS does not focus it][2]. In Safari on
261
- /// macOS, you can press <kbd>Tab</kbd> to focus a button (and fire a
262
- /// `focus` event) if [keyboard navigation is enabled in System Settings][3].
272
+ /// components which *do not* accept keyboard input (such as `<a>` and
273
+ /// `<button>` elements) when clicked or touched,
274
+ /// [following macOS conventions][2].
275
+ ///
276
+ /// In Safari on macOS, pressing <kbd>Option</kbd> + <kbd>Tab</kbd> will
277
+ /// allow you to focus components that does not accept keyboard input, and
278
+ /// will fire a `focus` event similarly to other platforms. If
279
+ /// [keyboard navigation is enabled in System Settings][3], pressing
280
+ /// <kbd>Tab</kbd> cycles focus between any component (like other
281
+ /// platforms).
282
+ ///
283
+ /// Safari will fire `focus` **and** (potentially-synthetic) `hover` events
284
+ /// for components which accept keyboard input (such as
285
+ /// `<input type="text">`) when clicked *or touched*. Touchscreen devices on
286
+ /// most other platforms will only fire `focus` events on touch, not
287
+ /// `hover`.
263
288
///
264
- /// [^1]: all browsers on iOS not using an [alternative engine ][4] (European Union only)
289
+ /// [^1]: [Outside of the European Union ][4], **all** browsers on iOS *also* use WebKit.
265
290
///
266
291
/// [0]: https://getbootstrap.com/docs/5.3/components/tooltips/#disabled-elements
267
292
/// [2]: https://webkit.org/b/22261#c68
@@ -270,20 +295,27 @@ pub struct TooltipProps {
270
295
#[ prop_or_default]
271
296
pub trigger_on_focus : TooltipFocusTrigger ,
272
297
273
- /// Show the tooltip when the [`target`][Self::target] node has the mouse
274
- /// cursor hovered over it.
298
+ /// Show the tooltip when the [`target`][Self::target] component has the
299
+ /// mouse cursor hovered over it.
275
300
///
276
301
/// This defaults to `true`, but [will not trigger on `disabled` elements][0].
277
302
///
278
303
/// **Note:** touchscreen devices and keyboard-only users *may not* trigger
279
304
/// hover events. Ensure there is some other way to trigger the tooltip on
280
305
/// those devices, such as with
281
- /// `trigger_on_focus={TooltipFocusTrigger::Always}`.
306
+ /// [ `trigger_on_focus={TooltipFocusTrigger::Always}`][1] .
282
307
///
283
308
/// Safari on iOS reports synthetic `mouseenter` events on touchscreen
284
- /// devices, but Android and desktop browsers traditionally do not.
309
+ /// devices, when browsers on other platforms with touchscreens
310
+ /// traditionally do not.
311
+ ///
312
+ /// However, [Safari on iOS does not fire `focus` events][2] for components
313
+ /// which do not accept keyboard input (such as `<a>` and `<button>`), so
314
+ /// synthetic `hover` events are the only way to trigger tooltips.
285
315
///
286
316
/// [0]: https://getbootstrap.com/docs/5.3/components/tooltips/#disabled-elements
317
+ /// [1]: Self::trigger_on_focus
318
+ /// [2]: https://webkit.org/b/22261#c68
287
319
#[ prop_or( true ) ]
288
320
pub trigger_on_hover : bool ,
289
321
0 commit comments