Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

feat: implement field filtering in FieldMenu with query support#3

Merged
caio-pizzol merged 4 commits intomainfrom
caio/sd-529-add-filtering-to-field-menu-on-double-curly-bracket-trigger
Oct 9, 2025
Merged

feat: implement field filtering in FieldMenu with query support#3
caio-pizzol merged 4 commits intomainfrom
caio/sd-529-add-filtering-to-field-menu-on-double-curly-bracket-trigger

Conversation

@caio-pizzol
Copy link
Contributor

@caio-pizzol caio-pizzol commented Oct 9, 2025

Note

Adds live query filtering to the field menu driven by trigger typing and switches DOCX export to use the editor API.

  • Editor/UX:
    • Add live query filtering for FieldMenu based on text typed after trigger in index.tsx (tracks trigger start, updates query, repositions menu, resets on close/select).
    • Improve trigger cleanup and position handling using triggerStart and current selection.
  • FieldMenu:
    • Extend props with filteredFields and filterQuery; render header, filter status, and “No matching fields”; display filtered list when provided.
  • Export:
    • Replace superdoc export with editor.exportDocx({ fileName }).
  • Types:
    • Update FieldMenuProps to include filteredFields and filterQuery.
  • Tests:
    • Remove src/__tests__/SuperDocTemplateBuilder.test.tsx and src/test/setup.ts.

Written by Cursor Bugbot for commit cb74d3a. This will update automatically on new commits. Configure here.

@linear
Copy link

linear bot commented Oct 9, 2025

SD-529 Add Filtering to Field Menu on Double Curly Bracket Trigger

Summary

Enable field menu filtering as users type after the {{ trigger, showing only matching fields.

Tasks

  • Detect when user types {{ to open the field menu
  • Capture subsequent keystrokes after the trigger
  • Filter availableFields array to show only fields matching the typed text
  • Update field menu display in real-time as user continues typing
  • Ensure field selection works with filtered results

Notes

The field menu component (src/defaults/FieldMenu.tsx) currently shows all available fields when triggered. We need to add state tracking for the search query and filter the displayed fields based on field label/category matching. The trigger detection logic exists in src/index.tsx where the editor's update event checks for {{ pattern.

… into caio/sd-529-add-filtering-to-field-menu-on-double-curly-bracket-trigger
… into caio/sd-529-add-filtering-to-field-menu-on-double-curly-bracket-trigger
@caio-pizzol
Copy link
Contributor Author

cursor review

@caio-pizzol caio-pizzol merged commit 34aa3ee into main Oct 9, 2025
2 checks passed
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Trigger Cleanup Fails to Remove Query Text

The trigger cleanup function captures the cursor position at trigger detection, causing it to only delete the trigger characters when executed, leaving any typed filter query text in the document. Additionally, menuTriggerFromRef.current is set to the position after the trigger, which causes incorrect menu dismissal when the cursor moves before the trigger.

src/index.tsx#L259-L267

const cleanup = () => {
const currentPos = e.state.selection.from;
const tr = e.state.tr.delete(triggerStart, currentPos);
e.view.dispatch(tr);
};
triggerCleanupRef.current = cleanup;
menuTriggerFromRef.current = from;

Fix in Cursor Fix in Web


@caio-pizzol caio-pizzol deleted the caio/sd-529-add-filtering-to-field-menu-on-double-curly-bracket-trigger branch October 9, 2025 18:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant