Skip to content

Fix/ drawer RTL bug #1446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/components/drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ class Drawer extends PureComponent<Props> {
constructor(props: DrawerProps) {
super(props);

this.leftRender = props.leftItem ? (Constants.isRTL ? this.renderRightActions : this.renderLeftActions) : undefined;
this.rightRender = props.rightItems
? Constants.isRTL
? this.renderLeftActions
: this.renderRightActions
: undefined;
this.leftRender = Constants.isRTL
? props.rightItems && this.renderRightActions
: props.leftItem && this.renderLeftActions;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not check if leftItem exists in the renderLeftActions method? (and the same for the rightItems...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually doesn't work.. the value of this.leftRender should be undefined and not () => undefined if the items don't exist.
I can write the methods that way, but I'm not sure if it makes it more clear:

  private renderLeftActions = this.props.leftItem
    ? (progress: Animated.Value /* , dragX: Animated.Value */) => {
      const {leftItem} = this.props;
      const leftItems = leftItem ? [leftItem] : undefined;
      return this.renderActions(leftItems, progress /* , dragX */);
    }
    : undefined;

this.rightRender = Constants.isRTL
? props.leftItem && this.renderLeftActions
: props.rightItems && this.renderRightActions;
}

private getLeftActionsContainerStyle = memoize((leftItem, rightItems) => {
Expand Down