Skip to content

Conditional formatting: New Formatting Rule dialog - #1202

Closed
iluebbe wants to merge 2 commits into
storytold:mainfrom
iluebbe:feat/cf-new-rule-dialog
Closed

iluebbe wants to merge 2 commits into
storytold:mainfrom
iluebbe:feat/cf-new-rule-dialog

Conversation

@iluebbe

@iluebbe iluebbe commented Oct 13, 2026 •

Copy link
Copy Markdown

Fixes #1165: home.conditionalFormat without a rule opened nothing.

Builds on #1199 (#1160, icon thresholds with ">"): the dialog's icon thresholds use that PR's command parameter. Please merge that one first. Until then this branch also contains its commit.

Problem

home.conditionalFormat without a rule asks the UI for the dialog newFormattingRule, and the UI had no dialog by that name. So these did nothing:

  • the key tips Alt, H, L, N (New Rule), and Alt, H, L, H / T / D, which run the same command until their submenus exist;
  • Search Commands › Conditional Formatting.

The ribbon's New Rule… opened a formula-only dialog instead, and none of the submenus had Excel's "More Rules…".

Fix

New Formatting Rule dialog (crates/ui-egui/src/dialogs/new_rule.rs). It has Excel's six rule types, each with its description fields:

Rule type Fields
Format all cells based on their values 2-colour scale and 3-colour scale (colours), data bar (colour, gradient or solid fill), icon sets (17 styles, reverse order, each icon's threshold with ">=" / ">", Number / Percent / Percentile / Formula, top icon first as in Excel)
Format only cells that contain cell value with any operator, specific text (containing / not containing / beginning / ending with), dates occurring, blanks, no blanks, errors, no errors
Format only top or bottom ranked values top or bottom, rank, % of the range
Format only values that are above or below average above, below, equal or above, equal or below, 1/2/3 std dev above or below
Format only unique or duplicate values duplicate or unique
Use a formula to determine which cells to format formula
  • Every type except the first has the format choice with a preview.
  • OK runs home.conditionalFormat with the rule the values describe.
  • The 17 icon styles are the ones a file's main conditional-format part can hold; Excel 2010's 3 Stars, 3 Triangles and 5 Boxes live only in its extension.

Entry points:

  • home.conditionalFormat without a rule opens the dialog, so Alt, H, L, N and Search Commands work.
  • The ribbon's New Rule… now runs the command.
  • Each Conditional Formatting submenu ends in More Rules…, which opens the dialog on that submenu's rule type, as in Excel.

Command: home.conditionalFormat takes equal and stdDev (1–3) for above/below-average rules. The model and the evaluator had them; the command always passed false / 0.

Control channel: ui.dialog.confirm now sends the parameters OK sends (dialogs::build_params). Before, it sent the raw field values. So the conditional-format dialogs can be confirmed over the channel; before, they arrived without their rule wrapper. The same goes for the other dialogs whose OK reshapes the values: Data Validation, Text to Columns, Remove Duplicates, Series and others.

preset_style (engine) is public, and the dialog's preview draws with it. The quick-format list and the date periods are shared with the existing quick-rule dialog.

Testing

  • tests/new_formatting_rule.rs (kittest):
    • the command without a rule opens the dialog, and More Rules… parameters pick the type;
    • picking "Format only unique or duplicate values" and pressing OK adds a duplicate rule;
    • over the control channel: 1 std dev above, bottom 3 %, begins with, an icon set with a ">" Number and a ">=" Percent threshold, and a formula rule, each set up and confirmed, checked in the model.
  • dialogs::new_rule unit tests: each rule type's parameters, defaults for More Rules…, colour parsing.
  • above_average_with_equal_and_standard_deviations (engine): stdDev and equal, with values measured in Excel. Over 0…10, 40 and 19, only 40 and 19 are more than one population standard deviation above the average. Over 1, 2, 3, "equal or above" and "equal or below" both take the 2.
  • cargo xtask ci: fmt, clippy, test, assets, layers and wasm pass.
    • parity and keytips report their generated files out of date on this Windows checkout (core.autocrlf).
    • Regenerating them changes only line endings: git diff is empty, as on main.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SAgnkqJiy3v24Hp25dQLRj

iluebbe and others added 2 commits October 13, 2026 22:38
…rytold#1160)

An icon set threshold is ">=" by default or ">", stored as gte="0" on its cfvo. GridCraft
ignored gte and compared with ">=", so a value exactly on a ">" threshold got the next icon
(Excel for Microsoft 365, 3 traffic lights over 0..10 with "> 3", "> 6": 3 is red and 6
yellow; GridCraft showed yellow and green).

CfRule::IconSet keeps a per-threshold `greater` flag (serde default, empty = all ">="); the
reader takes gte, the writer writes gte="0", the evaluator compares with ">" where it is set,
and home.conditionalFormat takes icon thresholds: [{type, value, operator: ">=" | ">"}].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAgnkqJiy3v24Hp25dQLRj
)

home.conditionalFormat without a rule asked the UI for the dialog `newFormattingRule`, which
didn't exist, so New Rule's key tip (Alt, H, L, N), the submenu key tips that run the same
command and Search Commands did nothing.

The dialog (dialogs/new_rule.rs) has Excel's six rule types with their description fields:
colour scales, data bars and icon sets with each icon's threshold (">=" or ">", number,
percent, percentile or formula); cell value, specific text, dates, blanks, errors; top or
bottom N or %; above or below average including "or equal" and 1-3 standard deviations;
unique or duplicate; formula; and the format with a preview. OK runs home.conditionalFormat.

New Rule… runs the command; every Conditional Formatting submenu ends in More Rules…, which
opens the dialog on that submenu's rule type. home.conditionalFormat takes `equal` and
`stdDev` for above/below-average rules. ui.dialog.confirm sends what OK sends
(dialogs::build_params), so dialogs that reshape their values confirm over the control
channel as they do on screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SAgnkqJiy3v24Hp25dQLRj
@iluebbe

iluebbe commented Oct 15, 2026

Copy link
Copy Markdown
Author

Closing this pull request. #1165 describes the dialog; its new comment adds Excel's layout per rule type and more measurements. The control-channel part is in #1459.

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.

Conditional formatting: home.conditionalFormat without a rule opens nothing (New Rule, Alt, H, L, N)

1 participant