Skip to content

Move input validation from init to updateView#108

Open
Philschke wants to merge 2 commits intoBenediktBergmann:masterfrom
Philschke:bugfix/fieldGetsCleared
Open

Move input validation from init to updateView#108
Philschke wants to merge 2 commits intoBenediktBergmann:masterfrom
Philschke:bugfix/fieldGetsCleared

Conversation

@Philschke
Copy link

📌 Overview

In addition to my recently raised issue #75,
I investigated the root cause and resolved it. This PR improves the control lifecycle by ensuring that input validation is performed in updateView instead of init.

❓ Why

According to Microsoft’s PCF guidelines:

Dataset and parameter values are not guaranteed to be initialized in init. Use updateView instead.

Running validation in init could therefore result in:

  • Invalid states
  • False errors
  • Unpredictable behavior during initialization

🔧 Changes Made

  • Removed checkInput call from init
  • Moved validation logic to updateView, where parameters are guaranteed to be populated
  • Kept init focused only on DOM setup and event handler registration
  • Only check the input if it´s actually changed

🎯 Benefits

  • Aligns control behavior with official PCF lifecycle best practices
  • Prevents race conditions and incorrect error states during initialization

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

Successfully merging this pull request may close these issues.

2 participants