Skip to content

Commit

Permalink
fix: remove editing layer when filter button clicked (nhn#1493)
Browse files Browse the repository at this point in the history
* fix: remove editing layer when filter button clicked

* chore: add test
  • Loading branch information
jajugoguma authored Oct 29, 2021
1 parent e6ec5d8 commit d9dbb8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/toast-ui.grid/cypress/integration/editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import GridEvent from '@/event/gridEvent';
import { CellValue } from '@t/store/data';
import { createCustomLayerEditor, CustomTextEditor } from '../helper/customEditor';
import { GridEventProps } from '@t/event';
import { clickFilterBtn } from '../helper/util';

before(() => {
cy.visit('/dist');
Expand Down Expand Up @@ -63,6 +64,7 @@ describe('with interaction', () => {
{
name: 'name',
editor: 'text',
filter: 'select',
},
{ name: 'age' },
];
Expand All @@ -81,6 +83,16 @@ describe('with interaction', () => {

cy.getByCls('layer-editing').should('be.not.visible');
});

it('should destroy the editing later and save editing, when fileter button clicked', () => {
cy.gridInstance().invoke('startEditing', 0, 'name');
cy.getByCls('content-text').type('Kim');

clickFilterBtn();

cy.getCell(0, 'name').should('have.text', 'Kim');
cy.getByCls('layer-editing').should('be.not.visible');
});
});

describe('onBeforeChange, onAfterChange', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/toast-ui.grid/src/view/filterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class FilterButtonComp extends Component<Props> {

if (!activeColumnAddress || activeColumnAddress.name !== columnName) {
const left = target.getBoundingClientRect().left - offsetLeft - DISTANCE_FROM_ICON_TO_LAYER;
dispatch('saveAndFinishEditing');
dispatch('setActiveColumnAddress', { name: columnName, left });
}
};
Expand Down

0 comments on commit d9dbb8f

Please sign in to comment.