Skip to content

Commit

Permalink
chore: update LemonUI types (#17755)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Oct 25, 2023
1 parent 886c804 commit 8b8cedf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions frontend/src/lib/lemon-ui/LemonMenu/LemonMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function LemonMenu({
)

const _onVisibilityChange = useCallback(
(visible) => {
(visible: boolean) => {
onVisibilityChange?.(visible)
if (visible && activeItemIndex && activeItemIndex > -1) {
// Scroll the active item into view once the menu is open (i.e. in the next tick)
Expand Down Expand Up @@ -256,7 +256,7 @@ const LemonMenuItemButton: FunctionComponent<LemonMenuItemButtonProps & React.Re
size={size}
{...buttonProps}
>
{label}
{label as string | JSX.Element}
{keyboardShortcut && (
<div className="-mr-0.5 inline-flex grow justify-end">
{/* Show the keyboard shortcut on the right */}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/lib/lemon-ui/LemonSelect/LemonSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface LemonSelectPropsNonClearable<T> extends LemonSelectPropsBase<T>

export type LemonSelectProps<T> = LemonSelectPropsClearable<T> | LemonSelectPropsNonClearable<T>

export function LemonSelect<T>({
export function LemonSelect<T extends string | number | boolean | null>({
value = null,
onChange,
onSelect,
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/lib/lemon-ui/LemonTable/TableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ function TableRowRaw<T extends Record<string, any>>({
// of a class indicating that scrollability to `table` caused the component to lag due to unneded rerendering of rows.
export const TableRow = React.memo(TableRowRaw) as typeof TableRowRaw

function isTableCellRepresentation(contents: React.ReactNode): contents is TableCellRepresentation {
function isTableCellRepresentation(
contents: React.ReactNode | TableCellRepresentation
): contents is TableCellRepresentation {
return !!contents && typeof contents === 'object' && !React.isValidElement(contents)
}
2 changes: 1 addition & 1 deletion frontend/src/lib/lemon-ui/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useLayoutEffect, useRef, useState } from 'react'
* @private
*/
export function useSliderPositioning<C extends HTMLElement, S extends HTMLElement>(
currentValue: string | number | null | undefined,
currentValue: React.Key | null | undefined,
transitionMs: number
): {
containerRef: React.RefObject<C>
Expand Down
19 changes: 11 additions & 8 deletions frontend/src/scenes/persons/RelatedFeatureFlags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ export function RelatedFeatureFlags({ distinctId, groups }: Props): JSX.Element
},
},
]

const options = [
{ label: 'All types', value: 'all' },
{
label: FeatureFlagReleaseType.ReleaseToggle,
value: FeatureFlagReleaseType.ReleaseToggle,
},
{ label: FeatureFlagReleaseType.Variants, value: FeatureFlagReleaseType.Variants },
]

return (
<>
<div className="flex justify-between mb-4">
Expand All @@ -131,14 +141,7 @@ export function RelatedFeatureFlags({ distinctId, groups }: Props): JSX.Element
<b>Type</b>
</span>
<LemonSelect
options={[
{ label: 'All types', value: 'all' },
{
label: FeatureFlagReleaseType.ReleaseToggle,
value: FeatureFlagReleaseType.ReleaseToggle,
},
{ label: FeatureFlagReleaseType.Variants, value: FeatureFlagReleaseType.Variants },
]}
options={options}
onChange={(type) => {
if (type) {
if (type === 'all') {
Expand Down

0 comments on commit 8b8cedf

Please sign in to comment.