Skip to content

fix(inline-tool-link): use defaultValue to prevent selectionchange event#2993

Merged
akulistus merged 5 commits intonextfrom
fix-inline-popover-re-renders
Mar 4, 2026
Merged

fix(inline-tool-link): use defaultValue to prevent selectionchange event#2993
akulistus merged 5 commits intonextfrom
fix-inline-popover-re-renders

Conversation

@akulistus
Copy link
Contributor

Problem:
Inline-popover re-renders constantly while text with link-tool formatting is selected.

Description:
Value assignment at line-215
causes a selectionchange event that triggers inline-popover re-render.

example
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>selectionchange demo</title>
</head>
<body>
  <button id="valueBtn">Set value</button>
  <button id="defaultValueBtn">Set defaultValue</button>
  <br /><br />

  <input id="input" />

  <script>
    const input = document.getElementById('input');

    document.addEventListener('selectionchange', () => {
      console.log('selectionchange');
    });

    document.getElementById('valueBtn').onclick = () => {
      input.value = 'value text';
      console.log('value set');
    };

    document.getElementById('defaultValueBtn').onclick = () => {
      input.defaultValue = 'defaultValue text';
      console.log('defaultValue set');
    };
  </script>
</body>
</html>

Issue:
#2987

Solution:
Change input value assignment to defaultValue to prevent the selectionchange event.

@Evgenii-Zinner
Copy link

Evgenii-Zinner commented Mar 3, 2026

This way when we use any tool on selected link, different button (bold or italic), we lose our link. This #2821 (comment) solution don't have this problem, while unlink button don't work this way either

@akulistus
Copy link
Contributor Author

Hello @Evgenii-Zinner!
Could you please provide an example of the described behavior and let me know which version of Editor.js you’re using? I tried to address this issue in version 2.31.3

@akulistus akulistus merged commit b69aa1e into next Mar 4, 2026
7 checks passed
@akulistus akulistus deleted the fix-inline-popover-re-renders branch March 5, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants