Skip to content

Commit

Permalink
fix(component): Ensure the inline edit save button functions for mark…
Browse files Browse the repository at this point in the history
…down editing

ref: #72
  • Loading branch information
jon-nfc committed Jan 29, 2025
1 parent 194ccc9 commit e078b1d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/MarkdownEditor.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import TextArea from "./form/Textarea";
import Button from "./form/Button";
import { useState } from "react";
import { useContext, useId, useState } from "react";
import RenderMarkdown from "../functions/RenderMarkdown";
import { Form } from "react-router";
import UserContext from "../hooks/UserContext";

/**
* Markdown Editor with preview tab.
Expand All @@ -26,6 +27,10 @@ const MarkdownEditor = ({

const [form_data, setFormData ] = useState({ [field_name]: data[field_name] })

const fieldsetFormId = useId();

const user = useContext(UserContext)


const handleChange = (e) => {

Expand Down Expand Up @@ -74,7 +79,7 @@ const MarkdownEditor = ({
console.debug('MarkdownEditor: ' + JSON.stringify(form_data))

return (
<Form name="inline_form" method="patch" action={String(data._urls._self).split('api/v2')[1]} onSubmit={handleSave}>
<Form id={fieldsetFormId} name="inline_form" method="patch" action={String(data._urls._self).split('api/v2')[1]} onSubmit={handleSave}>
<div
style={{
display: 'block',
Expand Down Expand Up @@ -102,6 +107,7 @@ const MarkdownEditor = ({
handleSave(e)
}}
/>
<input id="tz" type="hidden" name="tz" value={user.settings.timezone} />
<input id="metadata" type="hidden" name="metadata" value={JSON.stringify(metadata)} />
</>
}
Expand All @@ -123,6 +129,7 @@ const MarkdownEditor = ({
onClick = {onCancel}
/>
<Button
id="button-save"
button_text = 'Save'
/>
</div>
Expand Down

0 comments on commit e078b1d

Please sign in to comment.