Skip to content

#7128 Molecular formula letters are not on the same level#8912

Merged
AlexeyGirin merged 3 commits into
masterfrom
copilot/fix-molecular-formula-levels
Dec 16, 2025
Merged

#7128 Molecular formula letters are not on the same level#8912
AlexeyGirin merged 3 commits into
masterfrom
copilot/fix-molecular-formula-levels

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 15, 2025

How the feature works? / How did you fix the issue?

Molecular formula elements displayed with misaligned baselines due to trailing whitespace after subscript tags.

Before:

<span>
  {element}
  <sub>{count}</sub>{' '}  // Trailing space breaks baseline
</span>

After:

// Remove trailing space from component
<span>
  {element}
  <sub>{count}</sub>
</span>

// Add spacing at render level with conditional logic
.map((atom, index, array) => (
  <span key={`${atom}-${index}`}>
    <GrossFormulaPart part={atom} />
    {index < array.length - 1 ? ' ' : ''}
  </span>
))

Also fixes React key collision when duplicate atoms appear in formula by using atom-index composite key.

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request
Original prompt

This section details on the original issue you should resolve

<issue_title>Molecular formula letters are not on the same level</issue_title>
<issue_description>Steps to Reproduce

  1. Go to Macromolecules mode - Flex canvas (empty)
  2. Load from HELM: CHEM1{[CC[Md]PCC]}$$$$V2.0
    Image
  3. Open Calculate properties (press Alt+C)

Actual behavior
Molecular formula letters are not on the same level
Image

Expected behavior
Molecular formula letters are on the same level
Image

Environment details:

  • Ketcher Version 3.4.0-rc.3 Build at 2025-05-15; 19:51:50
  • Indigo Version 1.32.0-rc.2.0-g94ab270bd-wasm32-wasm-clang-19.0.0
  • Chrome Version 136.0.7103.93 (Official Build) (64-bit)
  • Win10

Found while testing: #5727</issue_description>

Comments on the Issue (you are @copilot in this section)

@SefaBilgii This issue is reproducible Image

Ketcher Version: 3.7.0-rc.1
OS: MacOs Sequoia Version 15.5
Browser : Chrome Version 138.0.7204.169
Indigo version 1.35.0-rc.1.0</comment_new>
<comment_new>@AlinaLysenko
Reproduced by agent - https://chatgpt.com/share/6930b0dd-c830-800e-8383-a671ca3e89cc</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 15, 2025 09:27
Remove trailing space from GrossFormulaPart component and add spaces between formula parts in the parent component to ensure all letters appear on the same baseline.

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Use combination of atom name and index as React key to handle cases where the same atom appears multiple times in the formula.

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix molecular formula letters alignment issue Fix molecular formula baseline alignment in Calculate Properties Dec 15, 2025
Copilot AI requested a review from AlexeyGirin December 15, 2025 09:32
@AlexeyGirin AlexeyGirin marked this pull request as ready for review December 15, 2025 15:12
@AlexeyGirin AlexeyGirin merged commit 3ced780 into master Dec 16, 2025
15 checks passed
@AlexeyGirin AlexeyGirin deleted the copilot/fix-molecular-formula-levels branch December 16, 2025 15:41
@AlexeyGirin AlexeyGirin changed the title Fix molecular formula baseline alignment in Calculate Properties #7128 Molecular formula letters are not on the same level Dec 16, 2025
AlexeyGirin added a commit that referenced this pull request Jan 3, 2026
* Initial plan

* Fix molecular formula letters alignment issue

Remove trailing space from GrossFormulaPart component and add spaces between formula parts in the parent component to ensure all letters appear on the same baseline.

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

* Address code review feedback - use unique React keys

Use combination of atom name and index as React key to handle cases where the same atom appears multiple times in the formula.

Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: AlexeyGirin <26869421+AlexeyGirin@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Molecular formula letters are not on the same level

3 participants