Skip to content

Conversation

Artur-
Copy link
Member

@Artur- Artur- commented Sep 28, 2025

  • Store the original Comparator object instead of just method references
  • Preserve SerializableComparator instances when provided
  • Respect custom reversed() implementations for descending sort

The column now stores the full comparator object, allowing it to:

  1. Use custom reversed() implementations when sorting descending
  2. Preserve serialization capability when SerializableComparator is provided
  3. Only create method references as a fallback for non-serializable comparators

Fixes #3926

…ialization (#3926)

- Store the original Comparator object instead of just method references
- Preserve SerializableComparator instances when provided
- Respect custom reversed() implementations for descending sort
- Fix serialization issues when non-serializable comparators are used

The column now stores the full comparator object, allowing it to:
1. Use custom reversed() implementations when sorting descending
2. Preserve serialization capability when SerializableComparator is provided
3. Only create method references as a fallback for non-serializable comparators

Fixes #3926

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@Artur-
Copy link
Member Author

Artur- commented Sep 28, 2025

The API seems to be a lie as there is setComparator(Comparator<T> comparator) but SerializableComparator<T> getComparator( SortDirection sortDirection) which does not in any way ensure the comparator is serializable

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the change breaks serialization:

java.lang.RuntimeException: serializeAndDeserializeUi_noExceptionIsThrown[any_Chrome_](com.vaadin.flow.component.grid.it.GridLitRendererSerializationIT)

Artur- and others added 4 commits October 4, 2025 15:59
Fixes issue where Grid ignored custom reversed() implementations when
sorting columns in descending order. Now stores both the comparator
and its reversed version at assignment time, preserving custom reverse
logic (e.g., for "favorites" that stay on top regardless of direction).

Fixes #3926

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copy link

sonarqubecloud bot commented Oct 8, 2025

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.

[Grid] Column ignores custom reversed comparator implementation
2 participants