Skip to content

Smarter cursor when the mask is shown #1488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
stanchev89 opened this issue Jan 8, 2025 · 0 comments
Open

Smarter cursor when the mask is shown #1488

stanchev89 opened this issue Jan 8, 2025 · 0 comments

Comments

@stanchev89
Copy link

stanchev89 commented Jan 8, 2025

🚀 feature request

Description

I would like to suggest a new feature or maybe enhancement on the current behavior with the following scenario:

  • A date input with mask 'M0/00', leadZeroDateTime="true", showMaskTyped - on dirty field.

When the customer fills the month value (ex. '02/__') the cursor position stays on the left side of the separator ('/') instead of the right. I guess that many of us can have different preferences here but especially when the mask is visible our teem need to provide better UX for the customer. When the cursor is not moved to the right side many of the customers are confused if they must do it manually and even if they want to do it they can't be sure which way is the right way.

In test it would looks like:

it('Mask M0/00 should set cursor on right position', () => {
cy.mount(CypressTestMaskComponent, {
componentProperties: {
mask: signal('M0/00'),
leadZeroDateTime: signal(true),
},
});
cy.get('#masked')
.type('3')
.should('have.value', '03/__')
.should('have.prop', 'selectionStart', 3);
});

Describe the solution you'd like

My proposal is whenever the mask is showed and the left side is completed and the current input event data is truthy (considering backspace scenarios) the cursor to be set after the separator position.

Describe alternatives you've considered

Currently we are using custom directive named expiryDateSmartCursor and we manually set the input selection range via setTimeout to avoid race conditions with the ngx-mask-directive actions

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

No branches or pull requests

2 participants