diff --git a/packages/format-library/src/link/index.native.js b/packages/format-library/src/link/index.native.js index 2588937f2d828..3a39485bce120 100644 --- a/packages/format-library/src/link/index.native.js +++ b/packages/format-library/src/link/index.native.js @@ -37,6 +37,7 @@ export const link = { attributes: { url: 'href', target: 'target', + rel: 'rel', }, edit: withSpokenMessages( class LinkEdit extends Component { diff --git a/packages/format-library/src/link/modal.native.js b/packages/format-library/src/link/modal.native.js index 67de419715954..a41c435df214b 100644 --- a/packages/format-library/src/link/modal.native.js +++ b/packages/format-library/src/link/modal.native.js @@ -19,6 +19,7 @@ const ModalLinkUI = ( { isVisible, ...restProps } ) => { hideHeader onClose={ restProps.onClose } hasNavigation + testID="link-settings-modal" > diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index 429927a3d10ed..71f4396b8fab2 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -17,6 +17,7 @@ For each user feature we should also add a importance categorization label to i - [*] Fix crash when trying to convert to regular blocks an undefined/deleted reusable block [#50475] - [**] Tapping on nested text blocks gets focus directly instead of having to tap multiple times depeding on the nesting levels. [#50108] - [*] Use host app namespace in reusable block message [#50478] +- [**] Configuring a link to open in a new tab no longer results in a partial loss of edit history (undo and redo) [#50460] ## 1.94.0 - [*] Split pasted content between title and body. [#37169] diff --git a/test/native/integration/editor-history.native.js b/test/native/integration/editor-history.native.js index acb3eb23192af..35ab4d54a0a08 100644 --- a/test/native/integration/editor-history.native.js +++ b/test/native/integration/editor-history.native.js @@ -3,12 +3,14 @@ */ import { addBlock, + dismissModal, getBlock, typeInRichText, fireEvent, getEditorHtml, initializeEditor, setupCoreBlocks, + selectRangeInRichText, within, } from 'test/helpers'; @@ -173,4 +175,62 @@ describe( 'Editor History', () => { " ` ); } ); + + it( 'should preserve editor history when a link has been added and configured to open in a new tab', async () => { + // Arrange + const initialHtml = ` +

A quick brown fox jumps over the lazy dog.

+ `; + const screen = await initializeEditor( { + initialHtml, + } ); + + // Act + const paragraphBlock = getBlock( screen, 'Paragraph' ); + fireEvent.press( paragraphBlock ); + + const paragraphTextInput = + within( paragraphBlock ).getByPlaceholderText( 'Start writing…' ); + selectRangeInRichText( paragraphTextInput, 2, 7 ); + fireEvent.press( screen.getByLabelText( 'Link' ) ); + + const newTabButton = screen.getByText( 'Open in new tab' ); + fireEvent.press( newTabButton ); + + dismissModal( screen.getByTestId( 'link-settings-modal' ) ); + + typeInRichText( + paragraphTextInput, + ' A quick brown fox jumps over the lazy dog.' + ); + + // Assert + expect( getEditorHtml() ).toMatchInlineSnapshot( ` + " +

A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.

+ " + ` ); + + // Act + fireEvent.press( screen.getByLabelText( 'Undo' ) ); + fireEvent.press( screen.getByLabelText( 'Undo' ) ); + + // Assert + expect( getEditorHtml() ).toMatchInlineSnapshot( ` + " +

A quick brown fox jumps over the lazy dog.

+ " + ` ); + + // Act + fireEvent.press( screen.getByLabelText( 'Redo' ) ); + fireEvent.press( screen.getByLabelText( 'Redo' ) ); + + // Assert + expect( getEditorHtml() ).toMatchInlineSnapshot( ` + " +

A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.

+ " + ` ); + } ); } );