ui-grid icon indicating copy to clipboard operation
ui-grid copied to clipboard

Focus on input lost (cellTemplate)

Open FUNimations opened this issue 10 years ago • 2 comments

There's an issue when you have a regularly updating datasource. Let's say i update my grid datasource with the latest values every 15 seconds and in my grid i have a templated column with an input field. (not edit mode)

lets say i have row ids: 1 , 2 , 3 , 4 , 5 And for my third row i start typing in the input field while someone deleted row 2. Now i have rowId's 1 , 3 , 4 , 5. Now rowId 3 is my second row in the grid. Whatever i have typed, it appears in the input field of the second row. Which is correct. However, focus is now set to the input of my third row, thus rowid 4. Which is wrong.

I've been able to figure out that in 'ui-grid/ui-grid-row' template a variable rowRenderIndex is used to identify my grid row, however, when the datasource is updated, this value doesn't change? I've tried replacing that variable with the id of my record row.entity.id, but upon datasource update i see an inconsistency between my json object and the id used in the html. In the html it keeps using the order 1,2,3,4,5, eventhough i no longer have a record with id 2.

Is there any way to keep focus on my record with id 3? Seems like there's a bug in here somewhere.

A plunker to demonstrate the issue: http://plnkr.co/edit/HIWWHwJa7YTQMrvp7b1c?p=preview Every 2 second i remove the first row. just start typing in the input field of record 8.

FUNimations avatar Jan 19 '16 14:01 FUNimations

Seems very similar to something solved in: http://webiks.com/sticky-row-in-md-virtual-repeat/. I've had the same issue there. I'll look into it to see if the solution offered there might fit in here. @c0bra - can you direct me with a look where should I focus attention? On second thought - maybe we could disable scrolling when we edit?

YonatanKra avatar Jan 24 '16 10:01 YonatanKra

Thanks for contributing! This repository has been transferred, and we're preparing the new 5.x release. We're closing older issues and pull requests as part of the reset. Please join us on Discord to follow the work or continue the conversation: https://discord.gg/Baz4w8ZWN

orneryd avatar Aug 12 '26 23:08 orneryd