Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b943258
Proof of concept
getdave Jan 18, 2024
b4bc075
Replace Unlink button in toolbar with edit link button
jeryj Jan 18, 2024
101723a
Avoid need for anchor hook
getdave Jan 19, 2024
bbde341
Activating a link via keyboard or toolbar goes to preview mode
getdave Jan 19, 2024
74a3e9e
Remove clickedLink state
jeryj Jan 22, 2024
cd51c57
Fix bug where no contentEditable would crash block
jeryj Jan 23, 2024
8fde809
Fix some e2e tests
jeryj Jan 23, 2024
b7659ef
Fix bug with collapsed selections at edge
getdave Jan 24, 2024
016a3ea
Revert unwanted stuff
getdave Jan 24, 2024
e7286f6
Revert "Revert unwanted stuff"
jeryj Jan 24, 2024
b7ba204
Revert "Fix bug with collapsed selections at edge"
jeryj Jan 24, 2024
ec501ea
Check for isActive before opening popover on link click
jeryj Jan 24, 2024
2f6b91e
Return focus to the element that opened the link control popover
jeryj Jan 24, 2024
94e332a
Use onFocusOutside to prevent stealing focus
jeryj Jan 24, 2024
9da61c7
Change name back to stopAddingLink
jeryj Jan 24, 2024
c59c5c0
Add comments
jeryj Jan 24, 2024
5091a0a
Only add link for email and urls if it's a new link
jeryj Jan 24, 2024
c006259
Update test for escape from link popover to return focus
jeryj Jan 24, 2024
76b89d3
Leave link UI open after initial creation
jeryj Jan 24, 2024
196d888
Fix createAndReselect test util
jeryj Jan 24, 2024
8ff163c
Fix keyboard shortcut tests
getdave Jan 25, 2024
c3200f2
Fix and simplify updating URL test
getdave Jan 25, 2024
21a8b12
Fix test for preserving state of advanced settings drawer
getdave Jan 25, 2024
3ff54ff
Fix test for toggling link settings
getdave Jan 25, 2024
2517f50
Fix link text change test
getdave Jan 25, 2024
7ab61d1
Update Edit Link -> Edit link
jeryj Jan 25, 2024
6b878f0
Change Edit link to Link
jeryj Jan 25, 2024
ba67044
Fix some tests
jeryj Jan 25, 2024
e75f2b1
Remove test no longer relevant
jeryj Jan 25, 2024
783a378
Remove unused test. Add test for onFocusOutside
jeryj Jan 25, 2024
abf7fcc
Hopefully fix test that is passing locally but failing on github
jeryj Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Fix bug with collapsed selections at edge"
This reverts commit b7659ef.
  • Loading branch information
jeryj committed Jan 24, 2024
commit b7ba20456f21a576f4beccff119115901fa1f7af
25 changes: 2 additions & 23 deletions packages/format-library/src/link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,6 @@ function Edit( {
} ) {
const [ addingLink, setAddingLink ] = useState( false );

const isSelectionCollapsed = isCollapsed( value );

const canMakeLink = ! isSelectionCollapsed && ! addingLink && ! isActive;

// There is a situation whereby there is an existing link in the rich text
// and the user clicks on the leftmost edge of that link and fails to activate
// the link format, but the click event still fires on the `<a>` element.
// This causes the `addingLink` state to be set to `true` and the link UI
// to be rendered in "creating" mode.
const collapsedSelectionInactiveLink = isSelectionCollapsed && ! isActive;

useLayoutEffect( () => {
const editableContentElement = contentRef.current;
if ( ! editableContentElement ) {
Expand Down Expand Up @@ -108,20 +97,12 @@ function Edit( {

return (
<>
{ canMakeLink && (
<RichTextShortcut
type="primary"
character="k"
onUse={ addLink }
/>
) }

<RichTextShortcut type="primary" character="k" onUse={ addLink } />
<RichTextShortcut
type="primaryShift"
character="k"
onUse={ onRemoveFormat }
/>

<RichTextToolbarButton
name="link"
icon={ linkIcon }
Expand All @@ -132,10 +113,8 @@ function Edit( {
shortcutCharacter="k"
aria-haspopup="true"
aria-expanded={ addingLink }
disabled={ collapsedSelectionInactiveLink }
/>

{ addingLink && ! collapsedSelectionInactiveLink && (
{ addingLink && (
<InlineLinkUI
addingLink={ addingLink }
stopAddingLink={ stopAddingLink }
Expand Down