Skip to content

unmask property usage with useIMask hook #1137

Description

@leadq

Hello,

I have a question regarding hook usage, and this behavior might potentially be a bug.

I’m not entirely sure if I fully understand the purpose of the unmask property. Based on the documentation, my understanding is that when unmask = true is provided, it controls whether the first value parameter returned from the onAccept callback should be the unmaskedValue or the maskedValue.

However, when using useIMask, even if I pass unmasked: true via the options, the value returned in onAccept is always the maskedValue. This seems inconsistent with the behavior I observe when using IMaskMixin. In that case, passing unmask: true correctly results in onAccept receiving the unmasked value.

Because of this discrepancy, I’m wondering whether this behavior is intentional or if it could be an issue specific to useIMask.

If this is of interest, I can try to provide a minimal reproduction example when I have some free time.

Thank you for your time and clarification.

My usage is basically like this:,

const _mask = useIMask(maskOptionsFromProps, {
  onAccept: (value, maskRef, event) => { 
     // due to value is not depending on "unmask" prop, 
     // I have to calculate real value depend on unmask prop and 
     onChange(realValue) 
  },
  onComplete: handleComplete,
  defaultValue: value
})

Packages:
react-imask: 7.6.1
imask: 7.6.1

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