mentionize 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  ![License](https://img.shields.io/badge/License-MIT-green?style=for-the-badge)
2
2
 
3
- <p align="center">
4
- <img src="./.github/assets/logo.png" width="700"/>
5
- </p>
3
+ <div align="center">
4
+ <img src="./.github/assets/logo.png" width="300" alt="Mentionize Logo" />
5
+ </div>
6
+
6
7
  <h1 align="center">
7
8
  Mentionize
8
9
  </h1>
@@ -95,6 +96,7 @@ Defines how a trigger character activates suggestions and how mentions are seria
95
96
  | `dropdownWidth?` | `number` | Dropdown width in pixels (default: 250) |
96
97
  | `loadingContent?` | `ReactNode` | Content shown while loading async results (default: `"Loading..."`) |
97
98
  | `renderDropdown?` | `(props: DropdownRenderProps) => ReactNode` | Full custom dropdown rendering |
99
+ | `dropdownPositionStrategy?` | `"fixed" \| "absolute"` | Positioning strategy for the dropdown (default: `"fixed"`). Use `"absolute"` inside CSS-transformed ancestors such as modals — see [Modals & CSS Transforms](#modals--css-transforms). |
98
100
  | `aria-label?` | `string` | Accessible label for the textarea |
99
101
  | `aria-describedby?` | `string` | ID of an element describing the textarea |
100
102
 
@@ -127,6 +129,27 @@ const trigger: MentionTrigger<User> = {
127
129
  };
128
130
  ```
129
131
 
132
+ ## Modals & CSS Transforms
133
+
134
+ Browsers create a new containing block for `position: fixed` elements when any ancestor has a CSS `transform` applied. This is a known browser behaviour that affects many libraries — the canonical example is a modal centred with `transform: translate(-50%, -50%)`, which causes any `position: fixed` child (including the suggestion dropdown) to be positioned relative to the modal rather than the viewport, placing it far off-screen.
135
+
136
+ Use `dropdownPositionStrategy="absolute"` to switch the dropdown to `position: absolute`, anchoring it to the `position: relative` container that `MentionInput` already renders internally:
137
+
138
+ ```tsx
139
+ <Dialog>
140
+ <DialogContent> {/* has transform: translate(-50%, -50%) */}
141
+ <MentionInput
142
+ dropdownPositionStrategy="absolute"
143
+ triggers={[userTrigger]}
144
+ value={value}
145
+ onChange={setValue}
146
+ />
147
+ </DialogContent>
148
+ </Dialog>
149
+ ```
150
+
151
+ The default is `"fixed"`, so all existing usage outside of transformed ancestors is unaffected.
152
+
130
153
  ## Cache Seeding via `parseMatch`
131
154
 
132
155
  By default the engine only recognizes mentions whose items are already cached (from `options`, `onSearch` results, or previous selections). When a mention is injected externally — for example by a `/` command picker or when loading initial content containing mentions for items that haven't been searched yet — the cache may not contain the underlying item, so the mention won't be highlighted or serialized.
@@ -12,6 +12,8 @@ interface MentionDropdownProps {
12
12
  position: CaretPosition;
13
13
  width: number;
14
14
  className?: string;
15
+ positionStrategy?: "fixed" | "absolute";
16
+ containerEl?: HTMLElement | null;
15
17
  }
16
18
  export declare const MentionDropdown: React.FC<MentionDropdownProps>;
17
19
  export {};