Skip to content

fix: derive {component} key placeholder from instances#103

Merged
dkrizan merged 1 commit into
tolgee:mainfrom
ZuzanaOdstrcilova:fix/component-key-from-instances
Jul 1, 2026
Merged

fix: derive {component} key placeholder from instances#103
dkrizan merged 1 commit into
tolgee:mainfrom
ZuzanaOdstrcilova:fix/component-key-from-instances

Conversation

@ZuzanaOdstrcilova

@ZuzanaOdstrcilova ZuzanaOdstrcilova commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Problem

When generating a key for a text node that lives inside a component instance, the {component} placeholder was left empty. Keys came out missing the component name — e.g. -log-in instead of component-log-in. A customer reported this.

The cause: getAllParents only matched parents of type COMPONENT / COMPONENT_SET. An instance node has type INSTANCE, so the component parent was never found for instances.

Fix

When an INSTANCE parent is encountered while walking the node hierarchy, resolve its main component and use its name. If the main component is a variant inside a component set, the set name is used so the key gets the recognizable component name.

  • Single, minimal change in src/main/utils/nodeParents.ts.
  • No new traversal and no async — mainComponent is read synchronously, consistent with the existing synchronous figma.getNodeById usage. No measurable performance impact.
  • Existing behavior for real components, frames, sections and groups is untouched.

Note

This uses the synchronous mainComponent getter, which matches the plugin's current (non dynamic-page) document access mode. If the plugin ever switches to documentAccess: "dynamic-page", this and the existing figma.getNodeById call would both need to move to their async equivalents.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved parent resolution so components nested through instances are now recognized correctly.
    • Component-related actions and navigation should work more reliably in instance-based structures.

Text nodes inside a component instance did not resolve the {component}
placeholder because getAllParents only matched COMPONENT / COMPONENT_SET
parents, not INSTANCE. Keys generated for instances lost the component
name (e.g. "-log-in" instead of "component-log-in").

Now when an INSTANCE parent is encountered, resolve its main component
(using the component set name when the main component is a variant).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b0930088-68c0-4f72-aedc-adfa5b8b76c1

📥 Commits

Reviewing files that changed from the base of the PR and between f1b742d and cbd7491.

📒 Files selected for processing (1)
  • src/main/utils/nodeParents.ts

Walkthrough

The getAllParents function in nodeParents.ts now handles INSTANCE type parents by resolving the instance's mainComponent and assigning it, or its containing COMPONENT_SET, to result.component when not already set.

Changes

Instance-based component resolution

Layer / File(s) Summary
Handle INSTANCE parent nodes
src/main/utils/nodeParents.ts
Adds a new branch in the parent traversal to resolve mainComponent from an INSTANCE node, assigning either the main component or its containing COMPONENT_SET to result.component when unset.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A hop through instances, deep and unseen,
To find the true component behind the screen,
No more do we lose the parent's trace,
Now instances lead us to the right place. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: deriving the {component} placeholder from instance parents.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/main/utils/nodeParents.ts

Oops! Something went wrong! :(

ESLint: 9.39.3

Error: ESLint configuration in --config » eslint-config-preact is invalid:

  • Unexpected top-level property "__esModule".

Referenced from: /.eslintrc.json
at ConfigValidator.validateConfigSchema (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2277:19)
at ConfigArrayFactory._normalizeConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3123:19)
at ConfigArrayFactory._loadConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3088:21)
at ConfigArrayFactory._loadExtendedShareableConfig (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3393:21)
at ConfigArrayFactory._loadExtends (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3261:25)
at ConfigArrayFactory._normalizeObjectConfigDataBody (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3199:25)
at _normalizeObjectConfigDataBody.next ()
at ConfigArrayFactory._normalizeObjectConfigData (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3144:20)
at _normalizeObjectConfigData.next ()
at ConfigArrayFactory.loadFile (/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2952:16)
(node:2) ESLintRCWarning: You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details. An eslintrc configuration file is used because you have the ESLINT_USE_FLAT_CONFIG environment variable set to false. If you want to use an eslint.config.js file, remove the environment variable. If you want to find the location of the eslintrc configuration file, use the --debug flag.
(Use node --trace-warnings ... to show where the warning was created)


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dkrizan
dkrizan merged commit b845c02 into tolgee:main Jul 1, 2026
4 checks passed
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.

3 participants