Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: emoji picker position error (#7497)

Mornc7d3d612ae87
diff --git a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/emoji_icon_widget.dart b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/emoji_icon_widget.dart
index 99b50c49c9..33333a3e92 100644
--- a/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/emoji_icon_widget.dart
+++ b/frontend/appflowy_flutter/lib/plugins/document/presentation/editor_plugins/header/emoji_icon_widget.dart
@@ -111,13 +111,10 @@ class _RawEmojiIconWidgetState extends State<RawEmojiIconWidget> {
try {
switch (widget.emoji.type) {
case FlowyIconType.emoji:
- return SizedBox(
- width: widget.emojiSize,
- child: EmojiText(
- emoji: widget.emoji.emoji,
- fontSize: widget.emojiSize,
- textAlign: TextAlign.justify,
- ),
+ return EmojiText(
+ emoji: widget.emoji.emoji,
+ fontSize: widget.emojiSize,
+ textAlign: TextAlign.justify,
);
case FlowyIconType.icon:
IconsData iconData =
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/emoji_picker/emoji_menu_item.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/emoji_picker/emoji_menu_item.dart
index ab952386bd..72aed27ad4 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/emoji_picker/emoji_menu_item.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/emoji_picker/emoji_menu_item.dart
@@ -33,15 +33,39 @@ void showEmojiPickerMenu(
Alignment alignment,
Offset offset,
) {
- final top = alignment == Alignment.topLeft ? offset.dy : null;
- final bottom = alignment == Alignment.bottomLeft ? offset.dy : null;
+ (double? left, double? top, double? right, double? bottom) getPosition() {
+ double? left, top, right, bottom;
+ switch (alignment) {
+ case Alignment.topLeft:
+ left = offset.dx;
+ top = offset.dy;
+ break;
+ case Alignment.bottomLeft:
+ left = offset.dx;
+ bottom = offset.dy;
+ break;
+ case Alignment.topRight:
+ right = offset.dx;
+ top = offset.dy;
+ break;
+ case Alignment.bottomRight:
+ right = offset.dx;
+ bottom = offset.dy;
+ break;
+ }
+
+ return (left, top, right, bottom);
+ }
+
+ final (left, top, right, bottom) = getPosition();
keepEditorFocusNotifier.increase();
late OverlayEntry emojiPickerMenuEntry;
emojiPickerMenuEntry = FullScreenOverlayEntry(
+ left: left,
top: top,
bottom: bottom,
- left: offset.dx,
+ right: right,
dismissCallback: () => keepEditorFocusNotifier.decrease(),
builder: (context) => Material(
type: MaterialType.transparency,
@@ -56,6 +80,7 @@ void showEmojiPickerMenu(
child: EmojiSelectionMenu(
onSubmitted: (emoji) {
editorState.insertTextAtCurrentSelection(emoji);
+ emojiPickerMenuEntry.remove();
},
onExit: () {
// close emoji panel
diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/emoji_picker/emoji_shortcut_event.dart b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/emoji_picker/emoji_shortcut_event.dart
index 078cf64963..5bb4766353 100644
--- a/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/emoji_picker/emoji_shortcut_event.dart
+++ b/frontend/appflowy_flutter/lib/workspace/presentation/settings/widgets/emoji_picker/emoji_shortcut_event.dart
@@ -35,7 +35,7 @@ CommandShortcutEventHandler _emojiShortcutHandler = (editorState) {
// Calculate the offset and alignment
// Don't like these values being hardcoded but unsure how to grab the
// values dynamically to match the /emoji command.
- const menuHeight = 200.0;
+ const menuHeight = 380.0;
const menuOffset = Offset(10, 10); // Tried (0, 10) but that looked off
final editorOffset =
@@ -47,7 +47,7 @@ CommandShortcutEventHandler _emojiShortcutHandler = (editorState) {
alignment = Alignment.topLeft;
final bottomRight = rect.bottomRight;
final topRight = rect.topRight;
- final newOffset = bottomRight + menuOffset;
+ var newOffset = bottomRight + menuOffset;
offset = Offset(
newOffset.dx,
newOffset.dy,
@@ -55,12 +55,12 @@ CommandShortcutEventHandler _emojiShortcutHandler = (editorState) {
// show above
if (newOffset.dy + menuHeight >= editorOffset.dy + editorHeight) {
- offset = topRight - menuOffset;
+ newOffset = topRight - menuOffset;
alignment = Alignment.bottomLeft;
offset = Offset(
newOffset.dx,
- MediaQuery.of(context).size.height - newOffset.dy,
+ editorHeight + editorOffset.dy - newOffset.dy,
);
}