fix(SW-1446): do not close modal on clear history
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
|||||||
} from "react-aria-components"
|
} from "react-aria-components"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
|
||||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||||
|
|
||||||
import styles from "./results.module.css"
|
import styles from "./results.module.css"
|
||||||
@@ -77,19 +76,15 @@ export function Results({
|
|||||||
href={item.url}
|
href={item.url}
|
||||||
className={styles.item}
|
className={styles.item}
|
||||||
textValue={item.displayName}
|
textValue={item.displayName}
|
||||||
|
// @ts-expect-error: pending https://github.com/adobe/react-spectrum/pull/8035
|
||||||
|
closeOnSelect={item.closesModal}
|
||||||
>
|
>
|
||||||
{item.id === "clearHistory" ? (
|
<>
|
||||||
<>
|
{item.icon ? item.icon : null}
|
||||||
<MaterialIcon icon="delete" color="CurrentColor" />
|
<Typography variant="Body/Supporting text (caption)/smBold">
|
||||||
<Typography variant="Body/Supporting text (caption)/smBold">
|
<Text slot="label">{item.displayName}</Text>
|
||||||
<Text slot="label">
|
</Typography>
|
||||||
{intl.formatMessage({
|
</>
|
||||||
id: "Clear searches",
|
|
||||||
})}
|
|
||||||
</Text>
|
|
||||||
</Typography>
|
|
||||||
</>
|
|
||||||
) : null}
|
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
)}
|
)}
|
||||||
</Collection>
|
</Collection>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import { useCallback, useMemo, useState } from "react"
|
|||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
import { useIsMounted, useMediaQuery } from "usehooks-ts"
|
import { useIsMounted, useMediaQuery } from "usehooks-ts"
|
||||||
|
|
||||||
|
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||||
|
|
||||||
import { isDefined } from "@/server/utils"
|
import { isDefined } from "@/server/utils"
|
||||||
|
|
||||||
import { ClientInline } from "./ClientInline"
|
import { ClientInline } from "./ClientInline"
|
||||||
@@ -132,7 +134,7 @@ export function JumpToClient<T extends JumpToData>({
|
|||||||
[data]
|
[data]
|
||||||
)
|
)
|
||||||
|
|
||||||
const latest: LocationMatchResults = useMemo(() => {
|
const latest = useMemo(() => {
|
||||||
if (data && history && history.length) {
|
if (data && history && history.length) {
|
||||||
const children = history
|
const children = history
|
||||||
.map((v) => {
|
.map((v) => {
|
||||||
@@ -141,7 +143,7 @@ export function JumpToClient<T extends JumpToData>({
|
|||||||
.filter(isDefined)
|
.filter(isDefined)
|
||||||
.slice(0, 5) // Only show five items
|
.slice(0, 5) // Only show five items
|
||||||
|
|
||||||
return [
|
const results: LocationMatchResults = [
|
||||||
{
|
{
|
||||||
id: "latestSearches",
|
id: "latestSearches",
|
||||||
name: "Latest searches",
|
name: "Latest searches",
|
||||||
@@ -154,11 +156,15 @@ export function JumpToClient<T extends JumpToData>({
|
|||||||
{
|
{
|
||||||
id: "clearHistory",
|
id: "clearHistory",
|
||||||
type: "clearHistory",
|
type: "clearHistory",
|
||||||
|
closesModal: false,
|
||||||
|
icon: <MaterialIcon icon="delete" color="CurrentColor" />,
|
||||||
displayName: intl.formatMessage({ id: "Clear searches" }),
|
displayName: intl.formatMessage({ id: "Clear searches" }),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
return results
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
}, [data, history, intl])
|
}, [data, history, intl])
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import type { ReactNode } from "react"
|
||||||
import type { Key } from "react-aria-components"
|
import type { Key } from "react-aria-components"
|
||||||
|
|
||||||
export type JumpToDataItem = {
|
export type JumpToDataItem = {
|
||||||
@@ -30,6 +31,8 @@ export type LocationMatch = {
|
|||||||
type: string
|
type: string
|
||||||
description?: string
|
description?: string
|
||||||
url?: string
|
url?: string
|
||||||
|
closesModal?: boolean
|
||||||
|
icon?: ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ScoringMatch = LocationMatch & {
|
export type ScoringMatch = LocationMatch & {
|
||||||
|
|||||||
Reference in New Issue
Block a user