Skip to content

Commit

Permalink
Attempt to fix unwanted position update
Browse files Browse the repository at this point in the history
The function position_changed? returns true even if the position remains the same. This because the corresponding method on the @positioned (`@positioned.position_changed?`) returns true (at least on my 7.1.3.2 version of ActiveRecord).
  • Loading branch information
multiscan authored May 14, 2024
1 parent 116aaf5 commit a6ad956
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/positioning/mechanisms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ def solidify_position

case position_before_type_cast
when Integer
self.position = position_before_type_cast.clamp(1..last_position)
clamped_position = position_before_type_cast.clamp(1..last_position)
self.position = clamped_position unless self.position == clamped_position
when :first, {after: nil}, {after: ""}
self.position = 1
when nil, "", :last, {before: nil}, {before: ""}
Expand Down

0 comments on commit a6ad956

Please sign in to comment.