kirbydesign / designsystem

Kirby Design System
https://cookbook.kirby.design
MIT License
83 stars 22 forks source link

[BUG] Segmented control does not scroll to active chip #3324

Open troelslenda opened 7 months ago

troelslenda commented 7 months ago

Describe the bug

With the following initial conditions, the active list item is not visible.

  1. Segmented control has more content than visible in a narrow viewport.
  2. The last element is the active one.

See enclosed screenshot

## Describe how to reproduce the bug 1. Apply this patch to cookbook:develop 3. Set the window size to 400px ```diff diff --git a/apps/cookbook/src/app/examples/segmented-control-example/default/default.ts b/apps/cookbook/src/app/examples/segmented-control-example/default/default.ts index 42002520b..d4c5937cb 100644 --- a/apps/cookbook/src/app/examples/segmented-control-example/default/default.ts +++ b/apps/cookbook/src/app/examples/segmented-control-example/default/default.ts @@ -8,6 +8,7 @@ const config = { [value]="selectedSegment" [mode]="mode" [size]="size" + [selectedIndex]="7" (segmentSelect)="onSegmentSelect($event)" > @@ -96,7 +97,7 @@ export class SegmentedControlExampleDefaultComponent implements OnInit { } codeSnippet = config.codeSnippet; - mode: SegmentedControlMode = SegmentedControlMode.default; + mode: SegmentedControlMode = SegmentedControlMode.compactChip; private _size: 'sm' | 'md' = 'md'; get size(): 'sm' | 'md' { ```

Which Kirby version was used?

9.0.0 / develop

## What was the expected behavior? That the list scrolls to show the last element as is does when clicked, like on second screenshot.

Add any screenshots

Screenshot 2024-01-10 at 14 01 20 Screenshot 2024-01-10 at 14 01 37

Please complete the following information:

Are there any additional context?


Checklist:

The following tasks should be carried out in sequence in order to follow the process of contributing correctly.

Verification

To make sure the bug is not intended behaviour; it should be verified by a member of team Kirby before moving on to implementation.

Implementation

The contributor who wants to implement this issue should:

Review

Once the issue has been implemented and is ready for review:

RasmusKjeldgaard commented 7 months ago

Is it your experience that is has worked like this before? It is useful to know if this is a regression or always has been like this, and I am not sure which it is.

troelslenda commented 7 months ago

I've tried the patch on v8.11.2 with no difference. It does not look like regression or in anyway related to v9.0.0 The issue was randomly discovered in a recent bughunt.