Skip to content

Conversation

@sadegh19b
Copy link
Contributor

This PR resolved the Issue #7 related to incorrect focus handling in OTP input fields, including autofocus, input navigation, paste behavior, and backspace handling. The changes involve improving focus logic using this.$nextTick() and refactoring the handleInput() and handlePaste() methods for better reliability. General changes code refactoring to enhance readability and maintainability and fixed styling were also included.

Also, change the rtl method to set default the condition to true.

Copy link

@mokhosh mokhosh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, can't we just rely on autofocus html attribute and remove JS logic for handling auto focus?

}

public function rtl(bool|\Closure $condition = false): static
public function rtl(bool|\Closure $condition = true): static
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be moved to a separate PR

:hint-actions="$getHintActions()"
:hint-icon="$getHintIcon()"
:required="$isRequired()"
:state-path="$getStatePath()"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can also be replaced with a variable if you're already extracting.

const input = e.target;
if(input.value.length > 1){
input.value = input.value.substring(0, 1);
state: $wire.$entangle('{{ $statePath }}'),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would separate style fixes and functional changes into separate PRs for easier reviews

@sadegh19b sadegh19b closed this Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants