Pode.Web icon indicating copy to clipboard operation
Pode.Web copied to clipboard

Allow empty string value to be supplied to Update-PodeWebTextbox

Open Badgerati opened this issue 2 years ago • 1 comments

Currently if you supply an empty string -Value to Update-PodeWebTextbox it doesn't do anything. It would be more appropriate for this to instead clear the textbox - but only if the value is explicitly set to an empty string. If the value is left as the default $null it won't do anything - for the use case of only updating the textbox's ReadOnly/Disabled state and not the value.

# update value
Update-PodeWebTextbox -Name 'Example' -Value 'Hi!'

# update value to empty - ie: clear
Update-PodeWebTextbox -Name 'Example' -Value ''

# only update the readonly state - don't update the value, leave it as is
Update-PodeWebTextbox -Name 'Example' -ReadOnlyState Enabled

Another possibility, similar to #475, we could maybe use $PSBoundParameters to check if -Value was supplied or not, and if not deal with it accordingly. This would allow empty and null to be explicitly supplied and clear the textbox, but when -Value not supplied it does nothing.

Badgerati avatar May 05 '23 22:05 Badgerati

I just tested $PSBoundParameters for none [switch] parameters and it should work as expected. So it should be possible to allow explicitly supplied null/empty strings to clear the textbox, and for the use case of not supplied -Value at all, we do nothing to the textbox's value.

Badgerati avatar May 05 '23 22:05 Badgerati