Skip to content

iOS safari OnInput binding forces cursor to the end of the input #33089

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

Closed
ericholland6 opened this issue May 27, 2021 · 3 comments
Closed

iOS safari OnInput binding forces cursor to the end of the input #33089

ericholland6 opened this issue May 27, 2021 · 3 comments
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Milestone

Comments

@ericholland6
Copy link

ericholland6 commented May 27, 2021

Describe the bug

In safari on iOS when tapping into OnInput event to set the value of a property, the cursor is forced to the end on every keystroke which makes editing characters in the middle of an entry difficult.

To Reproduce

@test
    <input @bind-value="@test" @bind-value:event="oninput" />
    @test2
    <input value="@test2" @oninput="(x) => test2 = x.Value.ToString()" />

@code
{
    string test { get; set; }
    string test2 { get; set; }
}
  1. Enter the code above into a page, view on iOS in safari (I use nGrok for this).
  2. Type string 'aaaa' into the first textbox.
  3. Move the cursor to the middle of the string then type in 'bb'. result should be 'aabbaa'
  4. Type string 'aaaa' into the second textbox.
  5. Move the cursor to the middle of the string then type in 'bb'. Notice the result is 'aabaab' due to the cursor moving to the end of the input when pressing the first 'b' character.

Clearly the two inputs are not equivalent as the documentation indicates. Is there a work-around I can use to get behavior matching the first input while still tapping into @oninput ?

Further technical details

.net 5.0

@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label May 28, 2021
@javiercn javiercn added the feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) label May 31, 2021
@javiercn javiercn added this to the Next sprint planning milestone May 31, 2021
@ghost
Copy link

ghost commented May 31, 2021

Thanks for contacting us.

We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@javiercn
Copy link
Member

@ericholland6 thanks for contacting us.

@SteveSandersonMS in case you have any thoughts, since you know more about this area.

@SteveSandersonMS
Copy link
Member

The difference between your two examples is that @bind contains a special behavior that knows not to write back to the DOM in reaction to the change/input event. We have an issue on the backlog saying it should be possible to enable the same behavior in non-@bind scenarios too: #17281

As such I'll close this as a duplicate of #17281.

In the meantime, I recommend you do use @bind and @bind:event="oninput". If there's something preventing you from doing that please let us know. If you need to trigger custom logic during typing, consider binding to a property with custom setter.

@SteveSandersonMS SteveSandersonMS added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Jun 16, 2021
@ghost ghost added the Status: Resolved label Jun 16, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-component-model Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc) ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

4 participants