Bug 1831803 Comment 1 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

The reason is that `tab` parameter is the reference to  `start` state   (and never point to the newest reference)
https://github.com/mozilla-mobile/firefox-android/blob/66544029a906ceb696ede2e58f176c7afa46e5e0/android-components/components/feature/customtabs/src/main/java/mozilla/components/feature/customtabs/CustomTabsToolbarFeature.kt#L238-L246

The suggested modification

```kotlin
    @VisibleForTesting
    internal fun addMenuItems(
        // tab: CustomTabSessionState, // Remove this parameter
        menuItems: List<CustomTabMenuItem>,
        index: Int,
    ) {
        menuItems.map { item ->
            SimpleBrowserMenuItem(item.name) {
                sessionId ?. let {
                    store.state.findCustomTab(it) ?. let {
                        item.pendingIntent.sendWithUrl(context, it.content.url)
                    }
                }
            }
        }.also { items ->
```

There're same issue with functions in this class like `addShareButton` , `addActionButton` .

`addCloseButton` just  use tab.id (and it wouldn't change)
The reason is that `tab` parameter is the reference of store.tab from the  `start`  function   (and never point to the newest reference)
https://github.com/mozilla-mobile/firefox-android/blob/66544029a906ceb696ede2e58f176c7afa46e5e0/android-components/components/feature/customtabs/src/main/java/mozilla/components/feature/customtabs/CustomTabsToolbarFeature.kt#L238-L246

The suggested modification

```kotlin
    @VisibleForTesting
    internal fun addMenuItems(
        // tab: CustomTabSessionState, // Remove this parameter
        menuItems: List<CustomTabMenuItem>,
        index: Int,
    ) {
        menuItems.map { item ->
            SimpleBrowserMenuItem(item.name) {
                sessionId ?. let {
                    store.state.findCustomTab(it) ?. let {
                        item.pendingIntent.sendWithUrl(context, it.content.url)
                    }
                }
            }
        }.also { items ->
```

There're same issue with functions in this class like `addShareButton` , `addActionButton` .

`addCloseButton` just  use tab.id (and it wouldn't change)

Back to Bug 1831803 Comment 1