Skip to content

Commit 2dafd89

Browse files
authored
fix: update sheet styles when active sheet is hidden (#4041)
1 parent bf683b0 commit 2dafd89

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/main/java/com/vaadin/flow/component/spreadsheet/tests/FreezePaneLocalePage.java‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
import java.net.URL;
77
import java.util.Locale;
88

9+
import org.apache.poi.ss.usermodel.SheetVisibility;
10+
911
import com.vaadin.flow.component.html.Div;
1012
import com.vaadin.flow.component.spreadsheet.Spreadsheet;
13+
import com.vaadin.flow.component.spreadsheet.framework.Action;
1114
import com.vaadin.flow.router.Route;
1215

1316
@Route("vaadin-spreadsheet/freeze-pane-locale")
@@ -30,6 +33,24 @@ public FreezePaneLocalePage() {
3033

3134
add(sheet);
3235

36+
SpreadsheetActionHandler handler = new SpreadsheetActionHandler();
37+
handler.addCellHandler(new SpreadsheetActionHandler.Cell() {
38+
@Override
39+
public void handleAction(Action action,
40+
Spreadsheet.SelectionChangeEvent sender,
41+
Spreadsheet target) {
42+
sheet.setSheetHidden(sheet.getActiveSheetPOIIndex(),
43+
SheetVisibility.HIDDEN);
44+
}
45+
46+
@Override
47+
public Action[] getActions(
48+
Spreadsheet.SelectionChangeEvent selection,
49+
Spreadsheet sender) {
50+
return new Action[] { new Action("Hide sheet"), };
51+
}
52+
});
53+
sheet.addActionHandler(handler);
3354
} catch (URISyntaxException e) {
3455
e.printStackTrace();
3556
} catch (IOException e) {

‎vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow-integration-tests/src/test/java/com/vaadin/flow/component/spreadsheet/test/FreezePaneLocaleIT.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,18 @@ public void loadSpreadsheetWithFrozenColumns_setLocaleAfterLoad_SpreadsheetLoade
1616
$(SpreadsheetElement.class).exists());
1717
}
1818

19+
@Test
20+
public void hideFirstSheet_borderStylesUpdated() {
21+
getDriver().get(getBaseURL() + "/freeze-pane-locale");
22+
setSpreadsheet($(SpreadsheetElement.class).first());
23+
24+
Assert.assertNotEquals("1px",
25+
getCellStyle("B5", "border-bottom-width"));
26+
27+
getCellAt(1, 1).contextClick();
28+
clickItem("Hide sheet");
29+
30+
Assert.assertEquals("1px", getCellStyle("B5", "border-bottom-width"));
31+
}
32+
1933
}

‎vaadin-spreadsheet-flow-parent/vaadin-spreadsheet-flow/src/main/java/com/vaadin/flow/component/spreadsheet/Spreadsheet.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,8 @@ public void setSheetHidden(int sheetPOIIndex, SheetVisibility visibility)
17021702
reloadActiveSheetData();
17031703
SpreadsheetFactory.reloadSpreadsheetData(this,
17041704
getActiveSheet());
1705+
1706+
getSpreadsheetStyleFactory().reloadActiveSheetCellStyles();
17051707
}
17061708
}
17071709
}

0 commit comments

Comments
 (0)