i have nested Section Groups as follows
SectionGroup "Features" SEC_GRP_FEATURES
SectionGroup "Contract Plus" SEC_GRP_FEATURES_CONTRACT_PLUS
Section /o "Building Contracts" SEC_FEATURE_CONTRACT_PLUS_BUILDING_CONTRACTS
MessageBox MB_OK "Building"
SectionEnd
Section /o "Vehicle Contracts" SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS
MessageBox MB_OK "Vehicle"
SectionEnd
SectionGroupEnd
SectionGroup "Asset Plus" SEC_GRP_FEATURES_ASSET_PLUS
Section /o "Depreciation" SEC_FEATURE_ASSET_PLUS_DEPRECIATION
MessageBox MB_OK "Depreciation"
SectionEnd
SectionGroupEnd
SectionGroupEnd Now using a !define MUI_PAGE_CUSTOMFUNCTION_PRE "SetFeatures"
i try to disable some features depending on a given license key, the code is as follows
Var /Global AmountFeatures
Var /Global AmountFeaturesAsset
Var /Global AmountFeaturesContract
StrCpy $AmountFeatures 2 ;Maximum Amount of Groups in Folder Features
StrCpy $AmountFeaturesAsset 1 ;Maximum Amount of features contained in Group SEC_GRP_FEATURES_ASSET_PLUS
StrCpy $AmountFeaturesContract 2 ;Maximum Amount of features contained in Group SEC_GRP_FEATURES_CONTRACT_PLUS
MessageBox MB_OK "AmountFeatures: $AmountFeatures$\r$\nAmountFeaturesAsset: $AmountFeaturesAsset$\r$\nAmountFeaturesContract :$AmountFeaturesContract"
Var /Global Inst_AssetPlus
Var /Global Inst_ContractPlus
ReadRegStr $Inst_AssetPlus HKLM "${REGKEY}" Inst_AssetPlus
ReadRegStr $Inst_ContractPlus HKLM "${REGKEY}" Inst_ContractPlus
MessageBox MB_OK "Inst_AssetPlus: $Inst_AssetPlus$\r$\nInst_ContractPlus: $Inst_ContractPlus"
${If} $Inst_AssetPlus != 1
MessageBox MB_OK "Remove Feature Asset Plus Depreciation"
!insertmacro ClearSectionFlag ${SEC_FEATURE_ASSET_PLUS_DEPRECIATION} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_ASSET_PLUS_DEPRECIATION} ""
IntOp $AmountFeaturesAsset $AmountFeaturesAsset - 1
${EndIf}
${If} $Inst_ContractPlus != 1
MessageBox MB_OK "Remove Features Contract Plus"
!insertmacro ClearSectionFlag ${SEC_FEATURE_CONTRACT_PLUS_BUILDING_CONTRACTS} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_CONTRACT_PLUS_BUILDING_CONTRACTS} ""
!insertmacro ClearSectionFlag ${SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS} ${SF_SELECTED}
SectionSetText ${SEC_FEATURE_CONTRACT_PLUS_VEHICLE_CONTRACTS} ""
IntOp $AmountFeaturesContract $AmountFeaturesContract - 2
${EndIf}
${If} $AmountFeaturesAsset = 0
MessageBox MB_OK "Remove Feature Group Asset Plus"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SECGRP}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_ASSET_PLUS} ${SF_SELECTED}
SectionSetText ${SEC_GRP_FEATURES_ASSET_PLUS} ""
IntOp $AmountFeatures $AmountFeatures - 1
${EndIf}
${If} $AmountFeaturesContract = 0
MessageBox MB_OK "Remove Feature Group Contract Plus"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SECGRP}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES_CONTRACT_PLUS} ${SF_SELECTED}
SectionSetText ${SEC_GRP_FEATURES_CONTRACT_PLUS} ""
IntOp $AmountFeatures $AmountFeatures - 1
${EndIf}
${If} $AmountFeatures = 0
MessageBox MB_OK "Remove Features Group"
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SECGRP}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SECGRPEND}
!insertmacro ClearSectionFlag ${SEC_GRP_FEATURES} ${SF_SELECTED}
SectionSetText ${SEC_GRP_FEATURES} ""
${EndIf} Now if both "Features" are enabled it looks like this:

If only the "Contract" Features are enabled it still looks fine.

But if the Contract Features are disabled and the Asset Features are enabled it looks weird like this 🙁

I am using NSIS Unicode 2.42-6.
any help would be much appreciated.
Thanks a lot.