Skip to content

Commit

Permalink
fix: trigger onPress for accordion and progress (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
dabrad26 authored Oct 18, 2023
1 parent 5e7732f commit 96ad210
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/components/Accordion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,15 @@ export class Accordion extends React.Component<AccordionProps> {
return <View style={this.styles.iconStyle}>{createIcon(open ? ChevronUpIcon : ChevronDownIcon, 22, 22, this.itemColor)}</View>;
}

private toggleDropdown = (): void => {
private toggleDropdown = (event: GestureResponderEvent): void => {
const { open } = this.state;
this.setState({ open: !open });
const { onPress } = this.props;

this.setState({ open: !open }, () => {
if (typeof onPress === 'function') {
onPress(!open, event);
}
});
};

componentDidUpdate(previosuProps: AccordionProps): void {
Expand Down
10 changes: 8 additions & 2 deletions src/components/ProgressIndicator/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,15 @@ export class ProgressIndicator extends React.Component<ProgressIndicatorProps> {
return <View style={this.styles.statusIcon}>{icon}</View>;
}

private toggleDropdown = (): void => {
private toggleDropdown = (event: GestureResponderEvent): void => {
const { open } = this.state;
this.setState({ open: !open });
const { onPress } = this.props;

this.setState({ open: !open }, () => {
if (typeof onPress === 'function') {
onPress(!open, event);
}
});
};

private getStateStyle = (state: PressableStateCallbackType): StyleProp<ViewStyle> => {
Expand Down

0 comments on commit 96ad210

Please sign in to comment.