material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[Slider] Always visible label still shows up when hiding its fragment

Open vikz95 opened this issue 1 year ago • 0 comments
trafficstars

Description When using version 1.11.0:

  • A slider with app:labelBehavior="visible" presents a bug on scroll, the label does not follow the new position of the slider. This bug was documented here https://github.com/material-components/material-components-android/issues/2869
  • When moving to a different fragment the slider labels of the former fragment are no longer visible

When using version 1.12.0-alpha03:

  • The https://github.com/material-components/material-components-android/issues/2869 issue is fixed
  • But when I hide a fragment and show another one under the same FragmentManager, the slider labels of the first fragment are not hidden and still show up.
  • Showing fragment of tab Setup 1, label position follows slider position on scroll as expected: label scroll fixed
  • Showing fragment of tab Setup 2, but also the labels of the Setup 1 fragment are visible: label still visible when changing fragment

Expected behavior: When hiding a fragment also the slider labels should be hidden.

Source code: I know that instead of adding all the fragments and hiding/showing them maybe I could use replace(), but in version 1.11.0 when hiding a fragment even the label is hidden as expected, so a bug was introduced in the alpha releases.

childFragmentManager.commit {
            setReorderingAllowed(true)
            add(R.id.call_setup_fragment_container, callSetupFragments[0], "Setup1")
            add(R.id.call_setup_fragment_container, callSetupFragments[1], "Setup2")
            hide(callSetupFragments[1])
            add(R.id.call_setup_fragment_container, callSetupFragments[2], "Setup3")
            hide(callSetupFragments[2])
            add(R.id.call_setup_fragment_container, callSetupFragments[3], "Setup4")
            hide(callSetupFragments[3])
        }

        binding.callSetupTabs.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
            override fun onTabSelected(tab: TabLayout.Tab?) {
                childFragmentManager.commit {
                    tab?.let { show(callSetupFragments[it.position]) }
                }
            }

            override fun onTabUnselected(tab: TabLayout.Tab?) {
                childFragmentManager.commit {
                    tab?.let { hide(callSetupFragments[it.position]) }
                }
            }

            override fun onTabReselected(tab: TabLayout.Tab?) {
            }

        })

Minimal sample app repro: Please consider attaching a minimal sample app that reproduces the issue. This will help narrow down the conditions required for reproducing the issue, and it will speed up the bug fix process. You may attach a zip file of the sample app or link to a GitHub repo that contains the sample app.

Android API version: 34

Material Library version: 1.12.0-alpha03

Device: Xiaomi Pad 6 and Samsung Galaxy tabS5e.

Edit: I tried also the latest SNAPSHOT version 1.12.0-SNAPSHOT and can confirm that the issues is still present.

vikz95 avatar Feb 14 '24 10:02 vikz95