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

Disabled button can be pressed issue/bug #7206

Merged
merged 5 commits into from
Dec 19, 2021
Merged

Conversation

Abdesol
Copy link
Contributor

@Abdesol Abdesol commented Dec 19, 2021

What does the pull request do?

Add IsEffectivelyEnabled condition to OnClick(from Button)

What is the updated/expected behavior with this PR?

If a controller is disabled(IsEnabled set to false), The Click event won't fire(work) unless the button is enabled.

Fixed issues

Fixes #6957

@Abdesol
Copy link
Contributor Author

Abdesol commented Dec 19, 2021

I added the test in the sandbox. If I did the test in the wrong place, let me know.

@maxkatz6
Copy link
Member

Thanks.
For tests you need to create a new test method in tests project. You can add it in this file https://github.com/AvaloniaUI/Avalonia/blob/master/tests/Avalonia.Controls.UnitTests/ButtonTests.cs
I think you can copy and edit this specific method https://github.com/AvaloniaUI/Avalonia/blob/master/tests/Avalonia.Controls.UnitTests/ButtonTests.cs#L273-L284 it already does what you need to test (raises click on some event). You just need to disable button in your test method and check that event was not raised.

p.s. it seems like these tests "Button_Invokes_CanExecute_When_CommandParameter_Changed" and "Raises_Click_When_AccessKey_Raised" are mixed, probably somebody renamed incorrectly by mistake.

@maxkatz6
Copy link
Member

Also you can just push commits to the same branch, you don't need to recreate PR

@Abdesol
Copy link
Contributor Author

Abdesol commented Dec 19, 2021

oh my bad.
I made a mistake in the test the assert should have been 0 ; (
Let me fix that

Copy link
Member

@maxkatz6 maxkatz6 left a comment

Choose a reason for hiding this comment

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

Looks good to me

@maxkatz6 maxkatz6 enabled auto-merge December 19, 2021 07:24
@maxkatz6
Copy link
Member

Thanks!

@maxkatz6 maxkatz6 merged commit 494746e into AvaloniaUI:master Dec 19, 2021
danwalmsley pushed a commit that referenced this pull request Dec 20, 2021
Disabled button can be pressed issue/bug
@maxkatz6 maxkatz6 added the bug label Dec 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disabled button can be pressed
3 participants