Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Public/Outputs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,10 @@ function Update-PodeWebTextbox
[string]
$Id,

[Alias('Height')]
[int]
$Size = 4,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make it so the default here is 0, so we can skip updating the textarea if no Size is passed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


[Parameter()]
[switch]
$AsJson,
Expand All @@ -536,12 +540,17 @@ function Update-PodeWebTextbox
$items = ($items | Out-String)
}

if ($Size -le 0) {
$Size = 4
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this part if default size is 0.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


return @{
Operation = 'Update'
ObjectType = 'Textbox'
Value = $items
ID = $Id
Name = $Name
Size = $Size
AsJson = $AsJson.IsPresent
Multiline = $Multiline.IsPresent
}
Expand Down
5 changes: 4 additions & 1 deletion src/Templates/Public/scripts/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ function setupSteppers() {
btn = stepper.find('.bs-stepper-content .bs-stepper-pane.active button.step-submit');
}

if (btn) {
if (btn && !isEnterKey(e)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the !isEnterKey(e) needed here? As ~9 lines up we do the same check and return 🤔

Copy link
Author

@ittchmh ittchmh Dec 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the && !isEnterKey(e) not set, it adding new line and execute Next button actio
7rAOMmPD46
n

btn.trigger('click');
}
});
Expand Down Expand Up @@ -2795,6 +2795,9 @@ function updateTextbox(action) {
}

txt.val(action.Value);
if (Number.isInteger(action.Size)) {
txt[0].rows = action.Size;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Size parameter is an [int] so the Number check isn't needed. It was also be worth checking that the textbox is a textarea as well, something like:

if (action.Multiline && action.Size > 0) {
    txt[0].rows = action.Size;
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}

function writeTextbox(action, sender) {
Expand Down
2 changes: 1 addition & 1 deletion src/Templates/Views/elements/textbox.pode
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
$events = ConvertTo-PodeWebEvents -Events $data.Events

if ($data.Multiline) {
$element = "<textarea class='form-control $(if ($data.NoForm) { 'no-form' })' id='$($data.ID)' name='$($data.Name)' pode-object='$($data.ObjectType)' placeholder='$($data.Placeholder)' rows='$($data.Size)' style='$($width) $($data.CssStyles)' $($describedBy) $($readOnly) $($required) $($value) $($events)></textarea>"
$element = "<textarea class='form-control $(if ($data.NoForm) { 'no-form' })' id='$($data.ID)' name='$($data.Name)' pode-object='$($data.ObjectType)' placeholder='$($data.Placeholder)' rows='$($data.Size)' style='$($width) $($data.CssStyles)' $($describedBy) $($readOnly) $($required) $($value) $($events)>$($data.Value)</textarea>"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth removing the $($value) property being set here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

}
else {
if ($data.Prepend.Enabled -or $data.Append.Enabled) {
Expand Down