Skip to content
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

Fix swipeable swiping to left when no renderRightActions is set #3145

Merged
merged 2 commits into from
Oct 11, 2024

Conversation

latekvo
Copy link
Contributor

@latekvo latekvo commented Oct 9, 2024

Description

Fixed Swipeable being able to be opened to the left when no right element is present.
This was caused by incorrectly set rightOffset, equal to 0 when no elements were present, even though it should've been set to rowWidth

Test plan

  • Open any swipeable example in the example app
  • Remove the renderRightActions prop
  • See how before this fix, Swipeable could've still been opened to the left, and now it can't be.

…ment is not present

(cherry picked from commit 2f511a3)
@latekvo latekvo requested review from m-bert and j-piasecki October 9, 2024 11:10
@latekvo latekvo changed the title fix swipeable detecting incorrect right element width, when right ele… Fix swipeable swiping to left when no renderRightActions is set Oct 9, 2024
@latekvo latekvo requested a review from m-bert October 10, 2024 13:27
if (rowState.value === 1) {
return leftWidth.value;
} else if (rowState.value === -1) {
return -rowWidth.value - rightOffset.value;
return -rowWidth.value - rightOffset.value!;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd think about changing it to use ternary operator:

      return rowState.value === 1
        ? leftWidth.value
        : rowState.value === -1
        ? -rowWidth.value - rightOffset.value!
        : 0;

But it has 3 options, so it may look a bit messy. It's up to you to decide 😅

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 looks ok, done in 5e8ded8

@latekvo latekvo merged commit 4b8bcf5 into main Oct 11, 2024
1 check passed
@latekvo latekvo deleted the @latekvo/fix-swipeable-when-no-elements-are-set branch October 11, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants