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

[BUG]: Calendar Control Automatically Hiding #213

Closed
justatheory opened this issue Dec 6, 2022 · 4 comments
Closed

[BUG]: Calendar Control Automatically Hiding #213

justatheory opened this issue Dec 6, 2022 · 4 comments
Assignees
Labels
Component: Calendar 👋 needs author feedback Waiting on a response from the author ❔question Issue is a question that requires an answer, not changes to code.

Comments

@justatheory
Copy link

justatheory commented Dec 6, 2022

Describe the bug

Calendar control is briefly visible then immediately hides without user interaction.

I have a text input to display the selected date from the calendar control. The text input's OnSelect property toggles a boolean variable (varShowCal) to control the visibility of the calendar control. If the calendar is hidden it sets varShowCal to true. If the calendar is displayed it hides the calendar by setting varShowCal to false.

The OnChange property of the calendar control sets varShowCal to false. In the published app when clicking the text input the calendar is briefly displayed before hiding automatically. It appears the OnChange of the calendar control is triggered the moment the user clicks on the text input which sets varShowCal to false and hides the calendar.

This automatic hiding only occurs the first time the text input is selected. This behaviour does not happen in the Power Apps editor experience.

To Reproduce
Steps to reproduce the behavior:

  1. Add text input and in OnSelect add UpdateContext({varShowCal: !varShowCal})
  2. Add calendar control. In the visible property of the calendar control add varShowCal
  3. Add UpdateContext({varShowCal: false}) to calendar control's OnChange property
  4. Default property of text input is set to Text(Calendar_1.SelectedDateValue,"ddd dd mmmm")

Expected behavior
I would like to click on the text input and have the calendar control display until the user selects a date or the text input is selected.

Additional context
This method works in an older app. I have updated the component in this app and replicated the functionality in a test app but in the test app it doesn't work. It appears OnChange is being fired when I set the visibility to true by clicking on the text input. The OnChange then hides the calendar without user input. When the user clicks the text input a 2nd time the calendar control works as expected.

@justatheory justatheory added bug Something isn't working ⚠️ needs triage Has not been triaged by the team yet. labels Dec 6, 2022
@justatheory
Copy link
Author

Edited to correct grammar.

@denise-msft
Copy link
Member

@justatheory thanks for your feedback and interesting scenario!

First of all, are you developing this in a canvas app or custom page?
It sounds like you're trying to replicate the Fluent UI DatePicker control that's available in custom pages. I recommend using that if you're using custom pages.

This behavior is happening because the value of SelectedDateValue changes from blank to the current date when you toggle the visibility of the Calendar (when it's hidden, the value is not set to anything). Therefore, a change is detected by the component and fires the OnChange event.

As a workaround, you can try adding an additional context variable that covers this first load situation:

Screen.OnVisible:

UpdateContext({ init: true })

Calendar1.OnChange:

If( init,
UpdateContext({ init: false });
,
UpdateContext({ varShowCal: false });
)

@denise-msft denise-msft added ❔question Issue is a question that requires an answer, not changes to code. 👋 needs author feedback Waiting on a response from the author Component: Calendar and removed bug Something isn't working ⚠️ needs triage Has not been triaged by the team yet. labels Dec 21, 2022
@justatheory
Copy link
Author

justatheory commented Dec 21, 2022 via email

@justatheory
Copy link
Author

@denise, I tried your workaround and it worked! Thank you for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Calendar 👋 needs author feedback Waiting on a response from the author ❔question Issue is a question that requires an answer, not changes to code.
Projects
None yet
Development

No branches or pull requests

2 participants