Skip to content

Conditional inline styles#2547

Merged
amazingphilippe merged 17 commits intomainfrom
conditional-inline-styles
Feb 11, 2026
Merged

Conditional inline styles#2547
amazingphilippe merged 17 commits intomainfrom
conditional-inline-styles

Conversation

@amazingphilippe
Copy link
Copy Markdown
Contributor

@amazingphilippe amazingphilippe commented Feb 3, 2026

Summary | Résumé

This PR adds styles for the inline conditional that should flow nicely within paragraph content. If the condition content has to wrap to the next line, it will do so gracefully without displacing the conditional widget or the content before and after.

It will not make everything look pretty, but it will try very hard to make what you have as clear as possible.

  • I tried working with variables to the side. While it looked nice and allowed you to preview more accurately the layout, it was a bit more confusing to navigate with the arrow key continuity thing.
  • The input is now a span that you can edit. This is required for Firefox where support for "field-sizing" is non existent.
Capture d’écran, le 2026-02-04 à 13 10 15 Capture d’écran, le 2026-02-04 à 13 10 22 Capture d’écran, le 2026-02-04 à 13 13 07

Test instructions | Instructions pour tester la modification

  • Insert an inline conditional in the middle of a paragraph and edit the contents

Comment on lines +382 to +397
/* @Will: Do we need this :before stuff? */
/* .conditional-block::before {
content: attr(data-condition);
position: absolute;
top: 0;
left: 0;
font-size: 0.75rem;
font-weight: 600;
color: white;
padding: 0.25rem 1rem;
white-space: nowrap;
}
} */

/* When a real label element is present (NodeView), hide the ::before fallback */
.conditional-block.has-conditional-label::before {
/* .conditional-block.has-conditional-label::before {
content: none;
}
} */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@whabanks I wasn't able to figure out the purpose of this. Removing it did not cause issues, but I may not have had the right steps to recreate the use case

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's likely a left over from an earlier iteration of the conditional, before we had the textbox and used the popover. We can safely remove this if you didn't notice any issues.

Copy link
Copy Markdown
Contributor

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 refactors the styling for inline conditionals to enable them to flow naturally within paragraph content. The changes remove the branch icon SVG from both block and inline conditionals, simplify the styling, and adjust the visual appearance to use box-shadow effects and small-caps text formatting.

Changes:

  • Removed branch icon SVG rendering from conditional components
  • Refactored CSS for inline conditionals to use box-shadow effects instead of borders
  • Simplified block conditional styling and removed top padding
  • Added new Tailwind utility classes for styling pseudo-elements and positioning

Reviewed changes

Copilot reviewed 3 out of 5 changed files in this pull request and generated 6 comments.

File Description
app/assets/stylesheets/index.css Added new Tailwind utility classes including pseudo-element styles, peer state variants, and positioning utilities
app/assets/javascripts/tiptap/editor.css Comprehensive refactoring of conditional styling with new inline flow-friendly CSS, removed deprecated browser-specific features, and simplified block conditional layout
app/assets/javascripts/tiptap/CustomComponents/ConditionalNodeView.js Removed SVG icon rendering from block conditional trigger
app/assets/javascripts/tiptap/CustomComponents/ConditionalInlineNode.js Removed SVG icon rendering from inline conditional widget

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

Comment thread app/assets/javascripts/tiptap/editor.css Outdated
Comment thread app/assets/stylesheets/index.css Outdated
Comment thread app/assets/javascripts/tiptap/editor.css
Comment thread app/assets/javascripts/tiptap/editor.css
Comment thread app/assets/javascripts/tiptap/editor.css Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 3, 2026

Copy link
Copy Markdown
Member

@andrewleith andrewleith left a comment

Choose a reason for hiding this comment

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

A few issues/questions:

  • I am not able to insert content after an inline conditional anymore (I can get the cursor to move before it though)

  • Round tripping to markdown inserts linebreaks

    • Image
    • Image
    • Image
    • Image
  • There is some padding or margin on the right-hand-side (before the letter d between the inlines) which makes me not sure if there is a space or not. I think there should be no gaps whatsoever here (or extremely small ones) so people know where they need to add spaces.

    • Image
  • There are several failing UI tests now. Some may be due to selectors changing, but at least some are behaviours that are no longer present. We should add tests to this pr to ensure the user can get before and after inline conditionals via the keyboard.

    • Focus exits input to the right when arrowing right inside conditional input
    • Focus enters the input on the left when arrowing right from outside conditional
    • Focus exits input to the left when arrowing left from inside conditional input
    • Focus enters the input on the right when arrowing left from outside conditional
    • Using toolbar, inline conditional: focus should be on condition input

Comment thread app/assets/javascripts/tiptap/CustomComponents/ConditionalNode.js Fixed
@amazingphilippe
Copy link
Copy Markdown
Contributor Author

amazingphilippe commented Feb 10, 2026

Added tests for:

Focus exits input to the right when arrowing right inside conditional input
 Focus enters the input on the left when arrowing right from outside conditional
Focus exits input to the left when arrowing left from inside conditional input
Focus enters the input on the right when arrowing left from outside conditional

This one already existed.

Using toolbar, inline conditional: focus should be on condition input

The cypress conditional test suite is now passing.
Removed the padding and margins that would look like spaces.
When adding a conditional, a space is also inserted if nothing comes after the conditional. this lets you place your cursor with better accuracy
I noticed FF and Chrome behave differently when Arrowing Left towards the condition content. I considered that in the tests. For humans, it shouldn't be a big annoyance.

The round trip bug is not introduced by this PR, we should fix it in a different PR.

Copy link
Copy Markdown
Member

@andrewleith andrewleith left a comment

Choose a reason for hiding this comment

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

This is looking really good.

I still find it a little hard to input back-to-back conditionals, but it does work. Sometimes its hard to get the cursor precisely where you want it (i.e. at the end of the conditional content or the start of the content afterwards), but honestly this isn't really any different than in Google docs or any other editor. Here is an example where I had to fuss a bit to get it how I wanted it:
Image

There are a few quirks, not sure if any are must-fix or not:

  • If you try to backspace the variable, when there is one char left in the name it stops you and focus jumps
  • if you double click the conditional content (or first word of it if its multiple words) the cursor moves to the end of the variable, instead of the start of the content
  • pressing backspace while at the start of the conditional content does weird things
  • unable to arrow up/down from the input sometimes (unsure about when because it does work in some cases)

@amazingphilippe amazingphilippe merged commit d59cd99 into main Feb 11, 2026
10 checks passed
@amazingphilippe amazingphilippe deleted the conditional-inline-styles branch February 11, 2026 14:03
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.

5 participants