Skip to content

Conversation

@adnaan
Copy link
Contributor

@adnaan adnaan commented Jan 25, 2026

Summary

  • Check for auto-generated _k field first in getItemKey() to support range items without explicit key attributes

Context

This is the client-side counterpart to livetemplate/livetemplate#108.

When templates don't define explicit key attributes (like data-key="{{.ID}}"), the server now injects a content-based hash into each item's _k field. This change ensures the client checks _k first, allowing proper key matching.

Test plan

  • All 193 existing tests pass
  • Works with server-side auto-key injection

🤖 Generated with Claude Code

Check for the auto-generated _k field first in getItemKey() to support
range items that don't have explicit key attributes in the template.

This works in conjunction with the server-side change that injects
_k fields into range items when no explicit key attribute is defined.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings January 25, 2026 11:51
@claude
Copy link

claude bot commented Jan 25, 2026

LGTM! Clean implementation of the auto-generated key support.

The priority order makes sense: _k field (server-injected hash) takes precedence over explicit key attributes. This ensures backward compatibility while supporting the new server-side auto-key injection.

No issues found:

  • Proper type check for _k as string
  • Early return pattern is efficient
  • Maintains existing fallback logic for explicit keys

Approved ✓

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds client-side support for auto-generated _k keys in range item matching, complementing the server-side auto-key injection feature from livetemplate/livetemplate#108. When templates don't define explicit key attributes, the server now injects content-based hashes into each item's _k field, and this change ensures the client checks that field first for proper item identification in range operations.

Changes:

  • Modified getItemKey() to prioritize the auto-generated _k field over explicit key attributes from rangeIdKeys

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adnaan adnaan merged commit 5d5f727 into main Jan 26, 2026
12 checks passed
@adnaan adnaan deleted the feat/auto-generated-range-keys branch January 26, 2026 17:06
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