selectize.js icon indicating copy to clipboard operation
selectize.js copied to clipboard

fix: ensure the parent of $testInput exists within the body

Open yfxie opened this issue 2 years ago • 2 comments

In some scenarios of using SPA, measureString can correctly calculate the width of $testInput on the first call. However, due to various possibilities, changes to the DOM will cause $testInput to leave the body, and the calculation result of measureString will always be 0. This PR ensures that $testInput always exists under the body to calculate the correct width.

The following is a rough example of reproducing the bug:

// Append $testInput to the body
$("input").appendTo("body").selectize(); 

// $testInput leaves the body
$("body").html(""); 

// measureString gets incorrect results
$("input").appendTo("body").selectize(); 

yfxie avatar Apr 12 '23 06:04 yfxie

This pull request is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Aug 13 '23 02:08 github-actions[bot]

@risadams can help review this PR?

yfxie avatar Aug 18 '23 08:08 yfxie

This pull request is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days

github-actions[bot] avatar Apr 21 '24 02:04 github-actions[bot]