Timothy Jaeryang Baek 3 weeks ago
parent
commit
1d0881e283
1 changed files with 26 additions and 1 deletions
  1. 26 1
      src/lib/components/common/RichTextInput/suggestions.ts

+ 26 - 1
src/lib/components/common/RichTextInput/suggestions.ts

@@ -48,7 +48,32 @@ export function getSuggestionRenderer(Component: any, ComponentProps = {}) {
 					theme: 'transparent',
 					placement: 'top-start',
 					offset: [-10, -2],
-					arrow: false
+					arrow: false,
+					popperOptions: {
+						strategy: 'fixed',
+						modifiers: [
+							{
+								name: 'preventOverflow',
+								options: {
+									boundary: 'viewport', // keep within the viewport
+									altAxis: true, // also prevent overflow on the cross axis (X)
+									tether: true,
+									padding: 8
+								}
+							},
+							{
+								name: 'flip',
+								options: {
+									boundary: 'viewport',
+									fallbackPlacements: ['top-end', 'bottom-start', 'bottom-end']
+								}
+							},
+							// Ensure transforms don’t cause layout widening in some browsers
+							{ name: 'computeStyles', options: { adaptive: true } }
+						]
+					},
+					// Helps avoid accidental focus/hover “linking” from far away elements
+					interactiveBorder: 8
 				});
 				popup?.show();
 			},