Fix fullscreen markdown editor crash and stale-value bugs (#25) - #26
Merged
Conversation
TRANSFORMERS.splice(0, 13) mutated the shared Lexical export in place
instead of copying it; slice fixes that. A formatting-state check
compared a boolean to the string "{}" and was always true; fixed to
compare the stringified state. MarkdownModal called onChange(inputVal)
from an effect keyed on [inputVal, onChange], firing on every render
whenever the parent passes a new onChange reference; onChange now
fires only from the TextField's own change handler, so it only
propagates actual user edits.
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.
Replaces PR #25 (not merged — kept the two real bugs it found, dropped the parts that made things worse).
Kept:
JSON.stringify(lastFormattingState === "{}")is always truthy); now compares the stringified state correctly.Not carried over from #25: deleting MarkdownModal's value-sync effect while leaving
useEffect(() => onChange(inputVal), [inputVal, onChange])— that still fires on every render when the parent passes an unstable onChange. Instead, removed that effect entirely and call onChange directly from the TextField's own change handler, so it only fires on actual user edits and the parent's onChange identity no longer matters.No B1App change needed — main's CreateEventModal already wires onChange to real setDescription state; the ref-only regression was specific to PR #519, which isn't being merged either.
Changeset included.