Fix emoji and improve js practices : Appliquer les bonnes pratiques JS et corriger le picker emoji qui se ferme au clic#38
Merged
Conversation
…deBlockGapClick.js. BLOCK_SELECTOR, VISUAL_TYPES and seen are never reassigned, making const safe and aligning with the rule forbidding var
…ns with arrow functions in ArticleViewer.jsx. Seven callbacks (effects, handlers, cleanup, catch) are converted to `() =>` since no `this` binding is used, making the change safe and consistent with the rule favoring arrow functions
…function with arrow functions in CopyBlockButton.jsx. Eleven vars become const/let and three functions become `() =>`, matching the rules that forbid var and prefer arrow functions
…tion with arrow functions in CustomFormattingToolbar.jsx. Fifteen vars become const and three functions become `() =>`, matching the rules that forbid var and prefer arrow functions
…tion with arrow functions in video‑override‑spec.js. Twenty‑one vars become const, four functions become `() =>`, while render and toExternalHTML keep function() because they rely on `this` via .call(). Matches the rules forbidding var and preferring arrow functions
…function with arrow functions in ArticleForm.jsx. Thirteen vars become const/let and fourteen functions become `() =>`, matching the rules that forbid var and prefer arrow functions
…s across core source and tests
…ick in the article editor. Adds a #bn-grid-suggestion-menu guard to capture‑phase mousedown handlers in ArticleForm.jsx and useCodeBlockGapClick.js to prevent cursor repositioning from closing the suggestion menu before emoji selection completes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objectif
Mettre en conformité le code React (source + tests) avec les règles §13 de AGENTS.md (var interdit, arrow functions préférées). Corriger le bug du picker emoji qui se ferme sans insérer au clic souris.
Changements
Bonnes pratiques JS (14 fichiers, +371/−368)
var → const/let dans les 6 composants et hooks source et 7 fichiers de test (BLOCK_SELECTOR, VISUAL_TYPES, variables de déstructuration, constantes de configuration).
function → () => : toutes les fonctions sans
thisconverties en arrow functions dans les fichiers source et de test. Exceptions :function()conservée dans video-override-spec.js (render, toExternalHTML — utilisentthisvia .call()) et dans les tests (mock ClipboardItem — arrow n'est pas un constructeur).1 violation stopPropagation corrigée : click → mousedown dans custom-code-block-spec.js:252. Test mis à jour.
Bug picker emoji (2 fichiers, +2/−2)
Cause : 2 handlers capture-phase mousedown dans ArticleForm.jsx et useCodeBlockGapClick.js interceptent le clic sur
.bn-grid-suggestion-menu-item sans guard, exécutent editor.setTextCursorPosition(...) → fermeture prématurée du menu de suggestion.
Fix : ajout de #bn-grid-suggestion-menu aux guards existants.
Fichiers modifiés
ArticleForm.jsx — 56 lignes : var→const/let, function→()=>, + guard emoji
ArticleViewer.jsx — 14 lignes : function→()=>
CopyBlockButton.jsx — 24 lignes : var→const/let, function→()=>
CustomFormattingToolbar.jsx — 36 lignes : var→const, function→()=>
video-override-spec.js — 46 lignes : var→const, function→()=> (sauf render/toExternalHTML)
useCodeBlockGapClick.js — 9 lignes : var→const, + guard emoji
custom-code-block-spec.js — 2 lignes : click→mousedown
7 fichiers de test — var→const/let, function→()=>, MockEvent('mousedown')