Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix-bug-558: adding column left or right unpredictable state #610

Merged
merged 7 commits into from
Jan 31, 2022

Conversation

gibsonliketheguitar
Copy link
Contributor

@gibsonliketheguitar gibsonliketheguitar commented Dec 27, 2021

#558

  • applying the single responsibility principle, to improve maintenance in the future.
  • Introduce new table action called 'insert' to replace 'handleSave' in NewColumn Component

Reason

handleModalSave === tableActions.column.update === updateColumn

 const menuModalProps = {
   ...
    handleSave: handleModalSave,
  };

const handleModalSave = (key: string, update: Record<string, any>) => {
    actions.update(key, update);
};
 
const actions: TableActions = { 
...
column: {
      ...
      update: configActions.updateColumn,
    },
}

const updateColumn = (key: string, updates: any) => {
    const { columns } = tableConfigState;

    const updatedColumns = {
      ...columns,                                   // this maintains previous index
      [key]: { ...columns[key], ...updates },       // this allows for duplicate index
    };
  };

Bug

  • a copy of a new column can result in duplicated indexes
  • after copy, the other column's index has to be updated

Solution

  • calculate the insert position, given left or right position, and handle the edge case
  • use _orderBy lodash to covert columns into a data structure where we can use .splice on
  • after insert, use reduce to rewrite index and return data into object format for dispatcher function

@gibsonliketheguitar gibsonliketheguitar changed the title fix-558 adding column left or right unpredictable state fix-bug-558: adding column left or right unpredictable state Dec 27, 2021
@notsidney notsidney marked this pull request as draft January 28, 2022 03:59
@gibsonliketheguitar gibsonliketheguitar marked this pull request as ready for review January 30, 2022 10:24
@gibsonliketheguitar
Copy link
Contributor Author

wait for #626 to be merge. 626 contains fix for keeping the index correct.
This feature breaks when columns are delete because index are not updated

@shamsmosowi shamsmosowi merged commit 0f2c037 into rowyio:develop Jan 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants