Skip to content

Commit 946cea3

Browse files
docs(slider): align documented focus surface with current behavior (#309)
* docs(slider): align documented focus surface with current behavior * docs(slider): address review feedback
1 parent b38cac6 commit 946cea3

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed

docs/styling/focus-styles.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ The following widgets accept `focusConfig`:
103103
| `input` | Suppresses focused input decoration |
104104
| `textarea` | Suppresses focused textarea decoration |
105105
| `select` | Suppresses focused select decoration |
106+
| `slider` | Suppresses focused slider highlight |
106107
| `virtualList` | Suppresses focused item highlight |
107108
| `table` | Suppresses focused row highlight |
108109
| `commandPalette` | Suppresses focused item highlight |

docs/widgets/catalog.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,9 +232,20 @@
232232
},
233233
{
234234
"name": "slider",
235-
"requiredProps": ["id", "value", "onChange"],
236-
"commonProps": ["min", "max", "step"],
237-
"example": "ui.slider({ id: 'vol', value: 42, onChange: setVol })"
235+
"requiredProps": ["id", "value"],
236+
"commonProps": [
237+
"min",
238+
"max",
239+
"step",
240+
"label",
241+
"showValue",
242+
"onChange",
243+
"readOnly",
244+
"focusable",
245+
"accessibleLabel",
246+
"focusConfig"
247+
],
248+
"example": "ui.slider({ id: 'vol', value: 42, min: 0, max: 100, onChange: setVol })"
238249
},
239250
{
240251
"name": "focusAnnouncer",

docs/widgets/slider.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ ui.slider({
2323
|---|---|---|---|
2424
| `id` | `string` | **required** | Unique identifier for focus and routing |
2525
| `value` | `number` | **required** | Current value |
26+
| `focusable` | `boolean` | `true` | Remove the slider from Tab order while keeping id-based routing available |
27+
| `accessibleLabel` | `string` | - | Optional semantic label for focus announcements and debugging |
2628
| `min` | `number` | `0` | Minimum value |
2729
| `max` | `number` | `100` | Maximum value |
2830
| `step` | `number` | `1` | Keyboard increment/decrement step |
@@ -33,6 +35,7 @@ ui.slider({
3335
| `disabled` | `boolean` | `false` | Disable focus and interaction |
3436
| `readOnly` | `boolean` | `false` | Keep focusable, but block value changes |
3537
| `style` | `TextStyle` | - | Optional style override |
38+
| `focusConfig` | `FocusConfig` | - | Control focus visuals; `{ indicator: "none" }` suppresses the focused slider highlight |
3639
| `key` | `string` | - | Reconciliation key |
3740

3841
## Behavior
@@ -42,7 +45,9 @@ ui.slider({
4245
- **Right/Up** increases by `step`.
4346
- **PageDown/PageUp** changes by 10 steps.
4447
- **Home/End** jumps to min/max.
48+
- `onChange` is optional; without it, the slider still renders and can receive focus, but it behaves as a non-editing control.
4549
- `readOnly` sliders still receive focus but do not emit `onChange`.
50+
- `focusConfig: { indicator: "none" }` keeps keyboard focus routing but suppresses the focused slider styling.
4651

4752
## Related
4853

packages/core/src/widgets/__tests__/slider.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,17 @@ describe("slider widget API", () => {
8080
assert.equal(fromUi.kind, "slider");
8181
assert.deepEqual(fromUi.props, props);
8282
});
83+
84+
test("slider accepts focusConfig without requiring onChange", () => {
85+
const props: SliderProps = {
86+
id: "volume-passive",
87+
value: 50,
88+
focusable: true,
89+
focusConfig: { indicator: "none" },
90+
};
91+
92+
const fromUi = ui.slider(props);
93+
assert.equal(fromUi.kind, "slider");
94+
assert.deepEqual(fromUi.props, props);
95+
});
8396
});

0 commit comments

Comments
 (0)