Skip to content

Incorrect top padding for ToastBar when shown using Component.TOP (since recent update) #4720

@ThomasH99

Description

@ThomasH99

Describe the bug
There is an empty space above the ToastBar text when showing it at the top of screen using Component.TOP.

Reproduce with the below code. When using setPosition(Component.BOTTOM) instead, it is shown correctly.

  Form hi = new Form("Test Toastbar", BorderLayout.center());
                Button button = new Button(Command.create("Show toastbar",null,(e)->{
                    ToastBar.getInstance().setPosition(Component.TOP);
                    ToastBar.Status myFormToastBar = ToastBar.getInstance().createStatus();
                    myFormToastBar.setMessage("Test test test test test test test test test test test test test test test test test");
                    myFormToastBar.setExpires(5000);
                    myFormToastBar.show();
                }));
                hi.add(BorderLayout.CENTER, button);
                hi.show();

The error has been introduced in one of the recent CN1 updates, and is probably due to these lines in ToastBar private ToastBarComponent getToastBarComponent(boolean create):

else if (position == Component.TOP && safeArea.getY() > 0) {
                Style s = c.getAllStyles();
                s.setPaddingUnit(Style.UNIT_TYPE_PIXELS);
                s.setPaddingTop(safeArea.getY()); // <<-- probably not correct
            }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions