Skip to content

bug: Fix paste issue in $('input#network').on('paste'...) #42

Description

@ranma2913
$('input#network').on('paste', function (e) {
    let pastedData = window.event.clipboardData.getData('text')
    if (pastedData.includes('/')) {
        let [network, netSize] = pastedData.split('/')
        $('#network').val(network)
        $('#netsize').val(netSize)
    }
    e.preventDefault()
});

First I noticed that my pasting data was being blocked most of the time. Appon analysis I found the issue was likely due to not trimming the pasted value. When double/tripple clicking a row in MacOS there is frequently a trailing whitespace of some kind which would end up causing the validation to fail.

Not to mention the preventDefault call was executing even when the pastedData didn't have a '/' char.

Also I get warnings about:

  • javascript:S1874 Deprecated APIs should not be used
  • CWE-477 - Use of Obsolete Functions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions