Skip to content

Commit

Permalink
fix active section index
Browse files Browse the repository at this point in the history
  • Loading branch information
rishavanand committed Oct 15, 2020
1 parent b9999e6 commit a42a047
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export const generateSectionTitleMarkdown = (props: SectionProps) => {
};

const Section = (section: SectionProps) => {
const [activeSectionIndex, setActiveSectionIndex] = useState(0);
const [activeColumnIndex, setActiveColumnIndex] = useState(0);
const [addFieldVisible, setAddFieldVisibility] = useState(false);
const [form] = Form.useForm();
Expand Down Expand Up @@ -130,7 +129,7 @@ const Section = (section: SectionProps) => {
form.validateFields()
.then((values: FieldProps & Required<Pick<FieldProps, 'type'>>) => {
form.resetFields();
addField(values, activeSectionIndex, activeColumnIndex);
addField(values, context.activeSectionIndex, activeColumnIndex);
})
.catch(info => {
console.log('Validate Failed:', info);
Expand Down Expand Up @@ -161,7 +160,7 @@ const Section = (section: SectionProps) => {
style={{ borderStyle: 'dashed' }}
onClick={() => {
setActiveColumnIndex(columnIndex);
setActiveSectionIndex(sectionIndex);
context.changeActiveSection(sectionIndex);
setAddFieldVisibility(true);
}}
size={buttonSize}
Expand Down Expand Up @@ -195,6 +194,7 @@ const Section = (section: SectionProps) => {
);

const toggleNameToMarkdown = (sectionIndex: number) => {
console.log(sectionIndex);
context.modifySection(
{
...section,
Expand Down Expand Up @@ -310,7 +310,7 @@ const Section = (section: SectionProps) => {
<RedoOutlined /> Start fresh
</Button>
<Popover
content={() => generateSectionSettings(activeSectionIndex)}
content={() => generateSectionSettings(context.activeSectionIndex)}
title="Section Settings"
>
<Button
Expand Down

0 comments on commit a42a047

Please sign in to comment.