Skip to content

Commit

Permalink
fix: when resizing textarea take params.width into consideration (#2654)
Browse files Browse the repository at this point in the history
  • Loading branch information
limonte committed Jul 15, 2023
1 parent 674916a commit 98b34a1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions cypress/e2e/inputs.cy.js
Expand Up @@ -371,6 +371,23 @@ describe('Inputs', () => {
})
})

it('popup should keep the custom width when textarea value is a promise', (done) => {
SwalWithoutAnimation.fire({
input: 'textarea',
width: 600,
inputValue: new Promise((resolve) => {
setTimeout(() => {
resolve('foo')
}, 10)
}),
})
setTimeout(() => {
expect(Swal.getInput().value).to.equal('foo')
expect(Swal.getPopup().style.width).to.equal('600px')
done()
}, 20)
})

it('returnInputValueOnDeny: true should pass the input value as result.value', (done) => {
SwalWithoutAnimation.fire({
input: 'text',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/dom/renderers/renderInput.js
Expand Up @@ -272,7 +272,7 @@ renderInputType.textarea = (textarea, params) => {
if (textareaWidth > initialPopupWidth) {
dom.getPopup().style.width = `${textareaWidth}px`
} else {
dom.getPopup().style.width = null
dom.applyNumericalStyle(dom.getPopup(), 'width', params.width)
}
}
new MutationObserver(textareaResizeHandler).observe(textarea, {
Expand Down

0 comments on commit 98b34a1

Please sign in to comment.