Skip to content

feat(text-editor): align hyperlink dialog with fusion DS#7857

Merged
tomdavies73 merged 2 commits intomasterfrom
FE-7626
Apr 21, 2026
Merged

feat(text-editor): align hyperlink dialog with fusion DS#7857
tomdavies73 merged 2 commits intomasterfrom
FE-7626

Conversation

@tomdavies73
Copy link
Copy Markdown
Contributor

@tomdavies73 tomdavies73 commented Mar 25, 2026

fix #7826

Proposed behaviour

Aligns the "hyperlink" Dialog within the TextEditor component with designs from the fusion DS. This fixes a current accessibility issue where the "Save" Button is disabled if any of the required fields are empty. This has instead been replaced with validation when the parent form is submitted.

This PR also introduces some new behaviour, when a user selects text before pressing the "Hyperlink" Button this selected text is populated in the "link text" Textbox when the Dialog opens

Current behaviour

Currently, the "hyperlink" Dialog within the TextEditor component is not aligned with the fusion DS and misses some key functionality. There is also an accessibility issue due to the use of a disabled button instead of form validation.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

  1. Open the "hyperlink" Dialog on this branch. See that the button is not disabled, and instead form validation is used if required fields are left empty
  2. Compare the open "hyperlink" Dialog when open to the available designs to check for proper continuity, these can be found by finding the linked Figma in the corresponding Jira tickets comments.
  3. Pre-select some text using your cursor. See that the selected text is now populated inside the "link text" Textbox when the Dialog opens

@tomdavies73 tomdavies73 self-assigned this Mar 25, 2026
@tomdavies73 tomdavies73 added DO NOT MERGE Work in progress This is a WIP PR so may not be ready for review labels Mar 25, 2026
@DipperTheDan DipperTheDan self-requested a review March 27, 2026 09:58
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the TextEditor “Insert link” dialog with the Fusion design system and improves accessibility by moving from a disabled “Save” button to submit-time validation, while also enhancing UX by pre-filling link text from the current selection.

Changes:

  • Updated hyperlink dialog copy/labels and introduced new i18n keys for required-field guidance and validation messages.
  • Implemented submit-time validation (instead of disabling the Save button) and auto-population of “Link text” from selected editor content.
  • Added/updated Storybook interaction coverage and unit tests for the new behaviors.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/locales/locale.ts Extends TextEditor hyperlink locale shape with new optional keys.
src/locales/en-gb.ts Updates hyperlink dialog copy and adds required-field + validation message strings.
src/components/text-editor/text-editor-interaction.stories.tsx Adds an interaction story to open the hyperlink dialog.
src/components/text-editor/internal/ui/Toolbar/toolbar.test.tsx Adds unit tests for selected-text prefill and submit-time validation.
src/components/text-editor/internal/ui/Toolbar/toolbar.component.tsx Implements new dialog layout, selection prefill, and validation flow.
src/components/text-editor/internal/ui/Toolbar/buttons/hyperlink.test.tsx Updates expected dialog title text.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +252 to +253
<CarbonProvider validationRedesignOptIn>
<StyledToolbarWrapper
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrapping the Toolbar in CarbonProvider will override any theme provided by a parent ThemeProvider/CarbonProvider (it defaults theme to sageTheme) and also re-initialises scoped tokens + modal context. This can cause the TextEditor toolbar/dialog to render with a different theme than the rest of the app. Instead, only opt into the new validation UI by providing NewValidationContext.Provider with validationRedesignOptIn: true around the dialog (or the specific Textboxes), without introducing a nested ThemeProvider.

Copilot uses AI. Check for mistakes.
Comment thread src/locales/locale.ts
Comment thread src/components/text-editor/__internal__/__ui__/Toolbar/toolbar.component.tsx Outdated
Copy link
Copy Markdown
Contributor

@nineteen88 nineteen88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: address baking in CarbonProvider into toolbar.component as discussed offline

@tomdavies73 tomdavies73 force-pushed the FE-7626 branch 2 times, most recently from 8080a6d to 4ed9c3e Compare April 1, 2026 14:48
DipperTheDan
DipperTheDan previously approved these changes Apr 7, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 196 to +204
/** Omitted from coverage, tested in hyperlink button */
/* istanbul ignore next */
const handleSubmit = (event: React.FormEvent) => {
event.preventDefault();

// Validate that both fields are not empty
const hasTextError = !linkText.trim();
const hasUrlError = !linkUrl.trim();

Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleSubmit is still marked with /* istanbul ignore next */, but it now contains the new validation behavior being introduced in this PR. Keeping it ignored will exclude the new logic from coverage reports and the comment is no longer accurate. Consider removing the ignore or narrowing it to only the truly untestable branch(es).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is intentionally excluded from coverage. Lexical's internal architecture makes deterministic test coverage difficult to achieve, and this is a known ongoing challenge across the codebase.

Existing tests provide meaningful behavioural coverage, but removing the /* istanbul ignore next */ directive would introduce disproportionate overhead to satisfy the 100% threshold without a commensurate improvement in test quality.

DipperTheDan
DipperTheDan previously approved these changes Apr 13, 2026
nineteen88
nineteen88 previously approved these changes Apr 13, 2026
Copy link
Copy Markdown

@LaiaSage LaiaSage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s possible that Accessibility may require an error summary in the future, but for now the current error handling is sufficient.

@LaiaSage
Copy link
Copy Markdown

LaiaSage commented Apr 17, 2026

As discussed via DM, thanks @tomdavies73 for working on moving the focus state to the first wrong field after error displayed. It will help a lot our keyboard users 😉

@LaiaSage
Copy link
Copy Markdown

Thanks for the updates, @tomdavies73 .
Although some of the spacing doesn’t exactly match the designs, I agree that this isn’t the main focus of this PR and can be addressed later if needed. So.. no blockers from my side 😊👍

@LaiaSage LaiaSage added Passed UX QA and removed Design System Review Required DS team to review changes labels Apr 20, 2026
@tomdavies73 tomdavies73 marked this pull request as draft April 20, 2026 08:25
aligns the hyperlink dialog within the TextEditor component with designs from the fusion DS. This
fixes a current accessibility issue where the "Save" button is disabled if any of the required
fields are empty. This has instead been replaced with validation when the parent form is submitted.
This PR also introduces some new behaviour, when a user selects text before pressing the "Hyperlink
button" this selected text is populated in the "link text" textbox when the dialog opens

fix #7826
@tomdavies73 tomdavies73 marked this pull request as ready for review April 20, 2026 09:58
@tomdavies73 tomdavies73 merged commit ed3eed9 into master Apr 21, 2026
29 checks passed
@tomdavies73 tomdavies73 deleted the FE-7626 branch April 21, 2026 15:20
@carbonci
Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 158.46.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

TextEditor - add link is not accessible

7 participants