Closed clarkwinkelmann closed 3 years ago
Something along the lines of:
const { setting, help, ...componentAttrs } = entry;
should fix it, with componentAttrs
being passed to the actual input elements instead of the full entry
object.
As a note, I used the following workaround in https://github.com/clarkwinkelmann/flarum-ext-emojionearea which is impacted by this issue.
// Workaround for https://github.com/flarum/core/issues/2728
override(AdminPage.prototype, 'buildSettingComponent', function (original, entry) {
return original({...entry});
});
Bug Report
Current Behavior The help text defined Using
ExtensionData.registerSetting()
disappears after the first Mithril redraw of the settings page.Steps to Reproduce
Use following javascript code:
Click switch:
Poof help text is gone and won't come back until next time the page is opened.
Expected Behavior Help text shouldn't disappear.
Environment
Possible Solution
The problem is here https://github.com/flarum/core/blob/706eaeda4153de130b8530713f00772df7146458/js/src/admin/components/AdminPage.js#L103
The
help
attribute isdelete
ed from the object, but since the object is modified by reference, it's gone forever.The object needs to be cloned before the
help
attribute is removed.That
delete
statement seems very out of place. Why do we removehelp
and notlabel
?Also there's likely a similar issue with
className
lower in the file where an additionalFormControl
class will be added on each redraw https://github.com/flarum/core/blob/706eaeda4153de130b8530713f00772df7146458/js/src/admin/components/AdminPage.js#L124