Skip to content

Cursor issue with dynamic masks #1136

Description

@lixiaoyan

Describe the bug
Assume we have an input with two dynamic masks: one is an empty string, and the other is a number with some prefix text. When we want to add some digits before an existing number, the cursor is placed incorrectly.

IMask(input, {
  mask: [
    {
      mask: "",
    },
    {
      mask: "$ d",
      lazy: false,
      expose: true,
      blocks: {
        d: {
          mask: Number,
          expose: true,
        },
      },
    },
  ],
});

To Reproduce
Open https://jsbin.com/voconifaze/edit?html,js,output then click "Run with JS" in the output panel.

Input 111 -> [$ 111|]
Place the cursor at the beginning of the number. -> [$ |111]
Input 2 then 2 -> [$ 211|1] -> [$ 2112|1]

Expected behavior
The value should be [$ 22|111]

Environment:

  • OS: macOS
  • Browser: Chrome
  • Version: 142.0.7444.176
  • IMask: 7.6.1

Additional context

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