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

ListSelectController::change_index should Eq instead of Data::same() #106

Open
maurerdietmar opened this issue Jan 22, 2022 · 7 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@maurerdietmar
Copy link
Collaborator

Just saw that ListSelectController::change_index() use Data::same() to compare values:

    fn change_index(&self, data: &mut T, next_else_previous: bool) {
        if let Some(mut index) = self.variants.iter().position(|variant| variant.same(data)) { 

IMHO this should use Eq to compare variants. This muse be exact - not best effort.

@richard-uk1
Copy link
Collaborator

So Data::same implies PartialEq::eq, ie. it is stronger. The trade-off is that it takes less time, but is allowed to have false falses. It is not allowed to have false trues.

@maurerdietmar
Copy link
Collaborator Author

So Data::same implies PartialEq::eq, ie. it is stronger. The trade-off is that it takes less time, but is allowed to have false falses.

Exactly this is the problem. See Druid Radio for a more correct implementation...

@richard-uk1
Copy link
Collaborator

Ahh I see.

@maurerdietmar
Copy link
Collaborator Author

Besides, do you know the difference between ListSelect and RadioGroup? I can see that items are rendered differently, but other functionality is quite the same? I just wonder if we can merge that into RadioGroup...

@maurerdietmar
Copy link
Collaborator Author

I just wonder if we can merge that into RadioGroup...

Just detected that Flutter also use 2 different widgets, so I guess people expect to have different widget for different visual style.

@richard-uk1
Copy link
Collaborator

Interesting though. Perhaps they could share the logic code (I don't know just thinking out loud).

@richard-uk1 richard-uk1 added bug Something isn't working help wanted Extra attention is needed labels Jan 26, 2022
@richard-uk1
Copy link
Collaborator

The original observation is definitely a bug though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants