Skip to content

ButtonStyle configuration.isPressed not updated properly #534

Open
@usmansc

Description

@usmansc

Describe the bug
ButtonStyle configuration.isPressed not updated properly

To Reproduce
The demo code is enough to reproduce the bug

Button("Pressed Button Style") {
    print("tapped")
}
.buttonStyle(
    PressedButtonStyle(pressedColor: Color.red)
)
struct PressedButtonStyle: ButtonStyle {
  let pressedColor: Color

  func makeBody(configuration: Configuration) -> some View {
    configuration.label
      .foregroundColor(configuration.isPressed ? pressedColor : .blue)
      .padding(15)
  }
}

Steps to reproduce the behavior:

  1. Press button and keep it pressed
  2. Move away from the button while still pressing the button
  3. Release
  4. Observe that .isPressed is still set to true

Expected behavior
.isPressed set to false and color change

Desktop (please complete the following information):

  • OS: [macOS 13.3.1]
  • Browser [chrome, safari]
  • Version of the browser [112.0.5615.137 and 16.4]
  • Version of Tokamak [0.11.0]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions