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

Button doesn't seem to get updates when there's a textfield in alert content #15

Closed
ynie opened this issue Mar 9, 2024 · 4 comments
Closed

Comments

@ynie
Copy link

ynie commented Mar 9, 2024

Hi, thank you for the great framework. I run into some issues where the alert buttons didn't get updated. Here's the code:

      .customAlert("Enter access code",
                     isPresented: $isShowingAccessCodeAlert,
                     content: {
            TextField("Access Code", text: $accessCode)
                .onSubmit {
                    submitCode()
                    isShowingAccessCodeAlert = false
                }
        }, actions: {
            MultiButton {
                Button(role: .cancel) {
                } label: {
                    Text("Cancel")
                }
                
                Button("Submit", action: submitCode)
                    .disabled(accessCode.trimmingCharacters(in: .whitespacesAndNewlines).count == 0)
                    .bold()
            }
        })

it doesn't seem like the button disable state is getting updated when the user starting to enter text. What did I do wrong? Thanks!

@divadretlaw
Copy link
Owner

Hi, well the current version doesn't support this due to a limitation of WindowKit which is used to display the alert.
I found a way around this limitation in WindowKit 2.1.0+ but for reasons unknown to me at the moment, the button don't update, even though they get redrawn.

I will continue to investigate this issue, hopefully I can find a solution, because this behavior seems very useful.

@ynie
Copy link
Author

ynie commented Mar 11, 2024

I fixed the issue by introducing an env variable and force the button to update. It's not great, but it does the trick case by case.

@divadretlaw
Copy link
Owner

Hi, this should be fixed in 3.5.0

Simulator Screen Recording - iPhone 15 - 2024-03-26 at 22 20 16

@ynie
Copy link
Author

ynie commented Mar 26, 2024

Thank you

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

No branches or pull requests

2 participants