yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.9k forks source link

MaskedInput Widget javascript update request #19988

Closed ldkafka closed 1 year ago

ldkafka commented 1 year ago

Please update the MaskedInput Widget javascript version - the bundled one is version Version: 3.3.11 from 2017. Current one is 5.0.8 from 2023.

I am not sure if there are any breaking changes, but a lot of bugs have been fixed - including datetime extension formatting (which is how I figured out the bundled version is too old).

Also, the alias configuration is very ambiguous - the Widget uses the $aliases array to supposedly register aliases, but that in fact is never used - aliases have to be configured in the clientOptions directly.

Thank you!

bizley commented 1 year ago

Hi, is there a chance you could prepare a PR fixing this?

stovesy commented 1 year ago

After this update I'm getting ... Uncaught SyntaxError: expected expression, got '<'jquery.inputmask.bundle.js:1:3 Uncaught TypeError: jQuery(...).inputmask is not a function

After checking, the file jquery.inputmask.bundle.js doesnt exist in the asset cache..

ldkafka commented 1 year ago

That is because jquery doesn't load fast enough... I'm seeing this quite a bit from CDNs lately. The other code should be wrapped in onLoad so it only runs when jquery is ready.

On Wed, 4 Oct 2023, 9:45 pm stovesy, @.***> wrote:

After this update I'm getting ... Uncaught SyntaxError: expected expression, got '<' jquery.inputmask.bundle.js:1:3 <https:/xxxxxx/xxxxx/xxxx/jquery.inputmask.bundle.js> Uncaught TypeError: jQuery(...).inputmask is not a function

— Reply to this email directly, view it on GitHub https://github.com/yiisoft/yii2/issues/19988#issuecomment-1746617337, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAM6ML5CRMNU7TWUWJ35UXTX5U44DAVCNFSM6AAAAAA5SAEB4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBWGYYTOMZTG4 . You are receiving this because you authored the thread.Message ID: @.***>

stovesy commented 1 year ago

class MaskedInputAsset extends AssetBundle { public $sourcePath = '@bower/inputmask/dist'; public $js = [ 'jquery.inputmask.js', ]; public $depends = [ 'yii\web\YiiAsset', ]; }

Fixes it for me, but I've no experience with this sort of thing.

terabytesoftw commented 1 year ago

@rob006 In the new version, change the name of the asset to:

'jquery.inputmask.bundle.js' to 'jquery.inputmask.js'

What is the best way to solve it, checking if the file exists, or deleting the old constraint, and leaving the new version.

rob006 commented 1 year ago

I don't know. IMO it shouldn't be part of the framework in the first place, so maybe extract this to separate package (which could have multiple versions targeting specific major version of inputmask plugin) and add it to require section of framework?