What could cause a View template to ouput wrong row index?
To solve it using views-view-field.html.twig
First in view settings, add field &quot;View Result Counter&quot; and hide from display.
Now in your twig you can do
&lt;div data-index=&quot;{{ view.field['counter'].getValue(row) }}&quot;&gt;...&lt;/div&gt;