Skip to content

Commit

Permalink
Support and document preventFocusOnPress (#6854)
Browse files Browse the repository at this point in the history
Support and document preventFocusOnPress (#6854)
  • Loading branch information
snowystinger authored Aug 22, 2024
1 parent 22e803a commit b4093df
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
1 change: 0 additions & 1 deletion packages/@react-aria/button/src/useButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export function useButton(props: AriaButtonOptions<ElementType>, ref: RefObject<
onPressEnd,
onPressUp,
onPressChange,
// @ts-ignore - undocumented
preventFocusOnPress,
// @ts-ignore - undocumented
allowFocusWhenDisabled,
Expand Down
1 change: 0 additions & 1 deletion packages/@react-aria/combobox/src/useComboBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ export function useComboBox<T>(props: AriaComboBoxOptions<T>, state: ComboBoxSta
...menuTriggerProps,
...triggerLabelProps,
excludeFromTabOrder: true,
// @ts-ignore - undocumented
preventFocusOnPress: true,
onPress,
onPressStart,
Expand Down
1 change: 0 additions & 1 deletion packages/@react-aria/searchfield/src/useSearchField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export function useSearchField(
clearButtonProps: {
'aria-label': stringFormatter.format('Clear search'),
excludeFromTabOrder: true,
// @ts-ignore
preventFocusOnPress: true,
isDisabled: isDisabled || isReadOnly,
onPress: onClearButtonClick,
Expand Down
9 changes: 8 additions & 1 deletion packages/@react-types/button/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ interface AriaBaseButtonProps extends FocusableDOMProps, AriaLabelingProps {
* The behavior of the button when used in an HTML form.
* @default 'button'
*/
type?: 'button' | 'submit' | 'reset'
type?: 'button' | 'submit' | 'reset',
/**
* Whether to prevent focus from moving to the button when pressing it.
*
* Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided,
* such as ComboBox's MenuTrigger or a NumberField's increment/decrement control.
*/
preventFocusOnPress?: boolean
}

export interface AriaButtonProps<T extends ElementType = 'button'> extends ButtonProps, LinkButtonProps<T>, AriaBaseButtonProps {}
Expand Down
19 changes: 15 additions & 4 deletions scripts/compareAPIs.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function getDiff(pair) {
${joinedResult}
\`\`\``;
}
diffs.push({iname, result: joinedResult, simplifiedName});
diffs.push({iname, result: joinedResult, simplifiedName: `${name.replace('/dist/api.json', '')}:${simplifiedName}`});
});

return {diffs, name};
Expand Down Expand Up @@ -535,9 +535,20 @@ function rebuildInterfaces(json) {
let name = property.name;
let optional = property.optional;
let defaultVal = property.default;
let value = processType(property.value);
// TODO: what to do with defaultVal and optional
funcInterface[name] = {optional, defaultVal, value};
// this needs to handle types like spreads, but need to build that into the build API's first
if (!property.value) {
name = 'UNKNOWN';
let i = 0;
while (funcInterface[name]) {
i++;
name = 'UNKNOWN' + String(i);
}
funcInterface[name] = {optional, defaultVal, value: property.type};
} else {
let value = processType(property.value);
// TODO: what to do with defaultVal and optional
funcInterface[name] = {optional, defaultVal, value};
}
});
let name = item.name ?? key;
if (item.typeParameters?.length > 0) {
Expand Down

1 comment on commit b4093df

@rspbot
Copy link

@rspbot rspbot commented on b4093df Aug 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.