jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
694 stars 124 forks source link

Weird behavior of enabled button in disabled container #3835

Closed gmmars closed 3 days ago

gmmars commented 3 weeks ago

Environment

Jmix version: 2.3.4 Jmix Studio plugin version: 2.3.3-242 IntelliJ version: IntelliJ IDEA 2024.2.4 (Ultimate Edition)

Bug Description

Weird behavior of enabled button in disabled container. Link to forum

Steps To Reproduce

Descriptor

<hbox width="100%" margin="false">
  <button id="tglLayoutBtn" text="toggle layout"/>
  <button id="tglTestBtn" text="toggle button"/>
</hbox>
<flexLayout id="buttonLayout">
  <button id="testBtn" text="test"/>
</flexLayout>

Sample code

@Subscribe(id = "tglLayoutBtn", subject = "clickListener")
public void onTglLayoutBtnClick(final ClickEvent<JmixButton> event) {
  boolean layoutEnabled = buttonLayout.isEnabled();
  buttonLayout.setEnabled(!layoutEnabled);
  event.getSource().setText("layout is "+(!layoutEnabled?"enabled":"disabled"));
}

@Subscribe(id = "tglTestBtn", subject = "clickListener")
public void onTglTestBtnClick(final ClickEvent<JmixButton> event) {
  boolean btnEnabled = testBtn.isEnabled();
  testBtn.setEnabled(!btnEnabled);
  event.getSource().setText("testBtn is "+(!btnEnabled?"enabled":"disabled"));
}

@Subscribe(id = "testBtn", subject = "clickListener")
public void onTestBtnClick(final ClickEvent<JmixButton> event) {
  notifications.show("Test Click!");
}

Current Behavior

Enabled Button in disabled Container is displayed as enabled. But when you click it, nothing hapends. Despite the Button is displayed as enabled, calling isEnabled() returns False.

Lood commented 3 weeks ago

In addition, the enabled button(tglTestBtn) in the enabled layout(hbox) is also not handled when layout(buttonLayout) is disabled.

glebfox commented 3 days ago

Cannot reproduce on Jmix 2.4.1. But anyway this is not Jmix issue.