Skip to content

Commit b4093df

Browse files
authored
Support and document preventFocusOnPress (#6854)
Support and document preventFocusOnPress (#6854)
1 parent 22e803a commit b4093df

File tree

5 files changed

+23
-8
lines changed

5 files changed

+23
-8
lines changed

packages/@react-aria/button/src/useButton.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ export function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<
5555
onPressEnd,
5656
onPressUp,
5757
onPressChange,
58-
// @ts-ignore - undocumented
5958
preventFocusOnPress,
6059
// @ts-ignore - undocumented
6160
allowFocusWhenDisabled,

packages/@react-aria/combobox/src/useComboBox.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,6 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta
346346
...menuTriggerProps,
347347
...triggerLabelProps,
348348
excludeFromTabOrder: true,
349-
// @ts-ignore - undocumented
350349
preventFocusOnPress: true,
351350
onPress,
352351
onPressStart,

packages/@react-aria/searchfield/src/useSearchField.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ export function useSearchField(
116116
clearButtonProps: {
117117
'aria-label': stringFormatter.format('Clear search'),
118118
excludeFromTabOrder: true,
119-
// @ts-ignore
120119
preventFocusOnPress: true,
121120
isDisabled: isDisabled || isReadOnly,
122121
onPress: onClearButtonClick,

packages/@react-types/button/src/index.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ interface AriaBaseButtonProps extends FocusableDOMProps, AriaLabelingProps {
5959
* The behavior of the button when used in an HTML form.
6060
* @default 'button'
6161
*/
62-
type?: 'button' | 'submit' | 'reset'
62+
type?: 'button' | 'submit' | 'reset',
63+
/**
64+
* Whether to prevent focus from moving to the button when pressing it.
65+
*
66+
* Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided,
67+
* such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.
68+
*/
69+
preventFocusOnPress?: boolean
6370
}
6471

6572
export interface AriaButtonProps<T extends ElementType = 'button'> extends ButtonProps, LinkButtonProps<T>, AriaBaseButtonProps {}

scripts/compareAPIs.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ function getDiff(pair) {
292292
${joinedResult}
293293
\`\`\``;
294294
}
295-
diffs.push({iname, result: joinedResult, simplifiedName});
295+
diffs.push({iname, result: joinedResult, simplifiedName: `${name.replace('/dist/api.json', '')}:${simplifiedName}`});
296296
});
297297

298298
return {diffs, name};
@@ -535,9 +535,20 @@ function rebuildInterfaces(json) {
535535
let name = property.name;
536536
let optional = property.optional;
537537
let defaultVal = property.default;
538-
let value = processType(property.value);
539-
// TODO: what to do with defaultVal and optional
540-
funcInterface[name] = {optional, defaultVal, value};
538+
// this needs to handle types like spreads, but need to build that into the build API's first
539+
if (!property.value) {
540+
name = 'UNKNOWN';
541+
let i = 0;
542+
while (funcInterface[name]) {
543+
i++;
544+
name = 'UNKNOWN' + String(i);
545+
}
546+
funcInterface[name] = {optional, defaultVal, value: property.type};
547+
} else {
548+
let value = processType(property.value);
549+
// TODO: what to do with defaultVal and optional
550+
funcInterface[name] = {optional, defaultVal, value};
551+
}
541552
});
542553
let name = item.name ?? key;
543554
if (item.typeParameters?.length > 0) {

0 commit comments

Comments
 (0)