Skip to content

fix(gui): open run-time pickers vertically centered like input prompts - #1799

Closed
chhoumann wants to merge 2 commits into
masterfrom
fix/1796-center-suggest-modals
Closed

chhoumann wants to merge 2 commits into
masterfrom
fix/1796-center-suggest-modals

Conversation

@chhoumann

@chhoumann chhoumann commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Picking from a Multi (or any QuickAdd run-time suggester) now opens the picker vertically centered, in the same spot as the VALUE prompt that follows it, instead of at core's fixed spot 80px from the top.

Obsidian anchors every SuggestModal (.prompt) at top: 80px, while QuickAdd's input prompts are regular modals that the container centers. So a single run jumped from the top of the window to the middle. ChoiceSuggester (the launcher and Multi picker) and SuggesterModal ({{VALUE:a,b,c}}, api.suggester, the input suggester) now call centerSuggestModal in onOpen.

Centering uses the height the picker has when it opens, not its live height. Plain flex centering would move the input on every keystroke as filtering shrinks the list, which is why core top-anchors these in the first place. If the list grows while you type (nested search), it's capped 80px above the bottom edge and scrolls. Mobile keeps core's layout (body:not(.is-mobile)).

Before/after on Obsidian 1.13.7. Red line = vertical center of the window

Verified in Obsidian 1.13.7 (the reporter's version) using the reporter's flow: a Multi with four Template choices, each asking {{VALUE:Title}}. 800px-tall window:

Before After
Multi picker, vertical center 183px 400px
Title prompt, vertical center 400px 400px
Picker input top, before / after filtering to one row - 298.5 / 298.5

Also checked by hand: {{VALUE:alpha,beta,gamma}} opens centered (400px). With nested search, a list that grows from 108px to 30 rows keeps the input still, stops 80px from the bottom, and scrolls. Mobile emulation still uses core's --prompt-top. Resizing the window while a picker is open keeps it on-screen: growing it keeps the input's offset, and shrinking 800px to 500px clamps the top to core's 80px (the picker spans 80-430px instead of pushing the input to y=-29).

Regression test: tests/e2e/picker-position.test.ts runs this flow in real Obsidian. It fails on master (expected 217.5 to be less than 2) and passes with the fix. The full E2E suite passed except one run of capture-cursor > refreshes cursor autocomplete when switching between body and property capture, a settings capture-builder test this change doesn't touch. It passed on 2/2 isolated reruns and on a full rerun of its file (39/39), so it looks flaky. pnpm run build-with-lint is clean and the unit suite passes (5758 tests).

Visual change: every QuickAdd run-time picker moves from the top to the middle of the window on desktop. Obsidian's own pickers (command palette, quick switcher) and QuickAdd's settings-time template discovery picker keep core's top position. No migration.

Fixes #1796

Note

Center run-time pickers vertically on desktop, like input prompts

  • Adds a centerSuggestModal helper in utils.ts that records the modal's rendered height in a CSS custom property and marks it for QuickAdd positioning.
  • Applies the helper in SuggesterModal.onOpen and ChoiceSuggester.onOpen so pickers open centered.
  • Adds desktop-only CSS in styles.css that centers the modal from the viewport midpoint and caps its height to the lower viewport area; the 80px top minimum is kept and mobile layouts are unchanged.
  • Adds an e2e test in picker-position.test.ts covering picker centering, input stability while filtering, and alignment with the following value prompt.

Macroscope summarized 23d6611.

Summary by CodeRabbit

  • Improvements
    • Suggestion pickers are now vertically centered on desktop, with their height adjusted to available screen space. Filtering suggestions keeps the input in place, and mobile layout remains unchanged.
  • Tests
    • Added checks for picker positioning before and after filtering, and for the value prompt’s alignment with the picker.

Core anchors suggest modals 80px from the top while QuickAdd's input
prompts are centered, so a Multi picker followed by a VALUE prompt
jumped across the screen. The choice picker and generic suggester now
open centered, pinned to their height at open so filtering doesn't move
the input.

Fixes #1796
@chhoumann chhoumann linked an issue Sep 25, 2026 that may be closed by this pull request
@chhoumann
chhoumann marked this pull request as ready for review September 25, 2026 22:11
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: a0123970-8d04-47a2-b75a-0ead33d652f6

📥 Commits

Reviewing files that changed from the base of the PR and between a1b8ecf and 23d6611.

📒 Files selected for processing (5)
  • src/gui/GenericSuggester/SuggesterModal.ts
  • src/gui/suggesters/choiceSuggester.ts
  • src/gui/suggesters/utils.ts
  • src/styles.css
  • tests/e2e/picker-position.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Suggester modals now record their height when opened and use desktop CSS to center them within the viewport. Both generic and choice suggesters apply the positioning helper. An end-to-end test checks picker position, input position after filtering, and value prompt position.

Changes

Prompt positioning

Layer / File(s) Summary
Positioning helper and desktop styles
src/gui/suggesters/utils.ts, src/styles.css
The helper records the modal’s open-time height and applies a CSS class. Desktop styles center matching modals and limit their maximum height.
Suggester integration and position test
src/gui/GenericSuggester/SuggesterModal.ts, src/gui/suggesters/choiceSuggester.ts, tests/e2e/picker-position.test.ts
Both suggester types call the helper when they open. The end-to-end test checks picker position, input position after filtering, and value prompt position.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 23d66

The picker-positioning change has no identified issue requiring a fix before merge. Proceed with normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #1796 requires the Multi-select dialog to align vertically with VALUE prompts. The PR calls centerSuggestModal from ChoiceSuggester.onOpen(), records the opening height, and applies the cent…
Out of Scope Changes check ✅ Passed The reported changes stay within runtime picker positioning. ChoiceSuggester, SuggesterModal, shared suggester utilities, desktop styles, and the picker-position regression test directly support t…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: vertically centering run-time pickers like input prompts.
Full details: Docstring Coverage

Explanation

Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

A rabbit taps the modal’s top,
It finds the height and sets the spot.
The picker settles near the middle,
The filtered input stays put and still.
Then value prompts align just right,
And bunny hops into the night.

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-25T22:15:27.716033Z 29bff40 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread src/styles.css Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29bff405eb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/styles.css Outdated
@chhoumann

Copy link
Copy Markdown
Owner Author

Closing in favor of #1802: centering pickers is Obsidian's default behavior to customize with CSS, not something QuickAdd should override. #1802 adds stable classes so users can do that with a snippet.

@chhoumann chhoumann closed this Sep 26, 2026
@chhoumann
chhoumann deleted the fix/1796-center-suggest-modals branch September 26, 2026 10:35
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.

[BUG] Multi-select dialog positioning

1 participant