Skip to content

Fix emoji and improve js practices : Appliquer les bonnes pratiques JS et corriger le picker emoji qui se ferme au clic#38

Merged
raynaldlao merged 8 commits into
masterfrom
fix-emoji-and-improve-js-practices
Jul 14, 2026
Merged

Fix emoji and improve js practices : Appliquer les bonnes pratiques JS et corriger le picker emoji qui se ferme au clic#38
raynaldlao merged 8 commits into
masterfrom
fix-emoji-and-improve-js-practices

Conversation

@raynaldlao

@raynaldlao raynaldlao commented Jul 14, 2026

Copy link
Copy Markdown
Owner

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 this converties en arrow functions dans les fichiers source et de test. Exceptions : function() conservée dans video-override-spec.js (render, toExternalHTML — utilisent this via .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')

…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
…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
@raynaldlao
raynaldlao requested a review from hlargitte July 14, 2026 11:47
@raynaldlao raynaldlao self-assigned this Jul 14, 2026

@hlargitte hlargitte left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM

@raynaldlao
raynaldlao merged commit 6cc2009 into master Jul 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants