diff --git a/CHANGELOG.md b/CHANGELOG.md
index f61ca14a..25967cc6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,9 +11,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- ``
- component for hiding elements in specific media
- ``
- - force children to get displayed as inline content
+ - force children to get displayed as inline content
- ``
- - `useOnly` property: specify if only parts of the content should be used for the shortened preview, this property replaces `firstNonEmptyLineOnly`
+ - `useOnly` property: specify if only parts of the content should be used for the shortened preview, this property replaces `firstNonEmptyLineOnly`
### Fixed
@@ -21,11 +21,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- create more whitespace inside `small` tag
- reduce visual impact of border
- ``
- - take Markdown rendering into account before testing the maximum preview length
+ - take Markdown rendering into account before testing the maximum preview length
- ``
- header-menu items are vertically centered now
- `Typography`
- - adjust displaying fallback symbols in different browsers
+ - adjust displaying fallback symbols in different browsers
+- ``
+ - Use the latest provided `onChange` function and `disabled` prop
### Changed
@@ -43,7 +45,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
### Deprecated
- ``
- - `firstNonEmptyLineOnly` will be removed, is replaced by `useOnly="firstNonEmptyLine"`
+ - `firstNonEmptyLineOnly` will be removed, is replaced by `useOnly="firstNonEmptyLine"`
## [25.0.0] - 2025-12-01
diff --git a/src/extensions/codemirror/CodeMirror.tsx b/src/extensions/codemirror/CodeMirror.tsx
index 1fb52353..805d6e3e 100644
--- a/src/extensions/codemirror/CodeMirror.tsx
+++ b/src/extensions/codemirror/CodeMirror.tsx
@@ -231,6 +231,10 @@ export const CodeEditor = ({
currentView.current = view
const currentReadOnly = React.useRef(readOnly)
currentReadOnly.current = readOnly
+ const currentOnChange = React.useRef(onChange)
+ currentOnChange.current = onChange
+ const currentDisabled = React.useRef(disabled)
+ currentDisabled.current = disabled
const [showPreview, setShowPreview] = React.useState(false);
// CodeMirror Compartments in order to allow for re-configuration after initialization
const readOnlyCompartment = React.useRef(compartment())
@@ -319,11 +323,11 @@ export const CodeEditor = ({
disabledCompartment.current.of(EditorView?.editable.of(!disabled)),
AdaptedEditorViewDomEventHandlers(domEventHandlers) as Extension,
EditorView?.updateListener.of((v: ViewUpdate) => {
- if (disabled) return;
+ if (currentDisabled.current) return;
- if (onChange && v.docChanged) {
+ if (currentOnChange.current && v.docChanged) {
// Only fire if the text has actually been changed
- onChange(v.state.doc.toString());
+ currentOnChange.current(v.state.doc.toString());
}
if (onSelection)