Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mobile][photos] Fix ghost preview when re-editing rotated text

r4khuld82848910f15
diff --git a/mobile/apps/photos/changes/image-editor-text-ghost.md b/mobile/apps/photos/changes/image-editor-text-ghost.md
new file mode 100644
index 0000000000..6e184e1006
--- /dev/null
+++ b/mobile/apps/photos/changes/image-editor-text-ghost.md
@@ -0,0 +1 @@
+- Fix a duplicate text preview when reopening enlarged or rotated text in the photo editor.
diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart
index 26745179d7..f2fa5673e3 100644
--- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart
+++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_layer_selection.dart
@@ -236,7 +236,7 @@ Future<void> _editTextLayer(ProImageEditorState editor, TextLayer layer) async {
key: editor.textEditor,
layer: (LayerCopyManager().copyLayer(layer) as TextLayer)
..fontScale = layer.fontScale * displayScale,
- heroTag: layer.rotation == 0 ? layer.id : null,
+ heroTag: layer.id,
configs: editor.configs.copyWith(
textEditor: editor.configs.textEditor.copyWith(
enableImageBoundaryTextWrap: layer.maxTextWidth != null,
diff --git a/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart b/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
index 4f6c0604a9..ad813d0f2d 100644
--- a/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
+++ b/mobile/apps/photos/test/ui/tools/editor/image_editor_text_test.dart
@@ -142,10 +142,25 @@ void main() {
final editor = await _openEditor(tester);
await _tap(tester, find.text('Done'));
+ final layer = editor.activeLayers.single as TextLayer;
+ layer
+ ..scale = 5
+ ..rotation = 0.02;
+ editor.setState(() {});
+ await tester.pumpAndSettle();
+ await _tap(tester, find.byTooltip('Edit'));
+ expect(find.byKey(layer.keyInternalSize), findsNothing);
+ await _tap(tester, find.text('Cancel'));
+ expect(find.byKey(layer.keyInternalSize), findsOneWidget);
+
+ await tester.tap(find.byKey(layer.keyInternalSize));
+ await tester.pumpAndSettle();
await _tap(tester, find.byTooltip('Edit'));
await tester.enterText(find.byType(TextField), 'Changed');
await _tap(tester, find.text('Done'));
expect((editor.activeLayers.single as TextLayer).text, 'Changed');
+ expect(editor.activeLayers.single.scale, 5);
+ expect(editor.activeLayers.single.rotation, 0.02);
editor.undoAction();
await tester.pumpAndSettle();