From 1c948b30d9131006ae12a911f4d3db33a23df762 Mon Sep 17 00:00:00 2001 From: Sam M <68707128+sam-m-m@users.noreply.github.com> Date: Wed, 24 Feb 2021 10:56:53 -0800 Subject: [PATCH] v0.9.2 -> v0.9.3 (#229) --- package-lock.json | 2 +- package.json | 2 +- src/components/Form/FormTimezone/index.tsx | 5 ++++- src/components/Modal/Modal.tsx | 3 ++- src/components/Timezone/index.tsx | 18 +++++++++++++++--- src/components/Timezone/utils.ts | 4 +--- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 990b8c7b..edb6f789 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@dassana-io/web-components", - "version": "0.9.2", + "version": "0.9.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2d639061..f3911112 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dassana-io/web-components", - "version": "0.9.2", + "version": "0.9.3", "publishConfig": { "registry": "https://npm.pkg.github.com/dassana-io" }, diff --git a/src/components/Form/FormTimezone/index.tsx b/src/components/Form/FormTimezone/index.tsx index 10dddcca..fe0697a4 100644 --- a/src/components/Form/FormTimezone/index.tsx +++ b/src/components/Form/FormTimezone/index.tsx @@ -48,7 +48,10 @@ const FormTimezone: FC = ({ loading={loading} onChange={value => { onChange(value) - triggerSubmit && triggerOnSubmit(value) + triggerSubmit && + triggerOnSubmit( + (value as unknown) as ChangeEvent + ) }} value={value} {...rest} diff --git a/src/components/Modal/Modal.tsx b/src/components/Modal/Modal.tsx index 9aff01bd..bc54fd98 100644 --- a/src/components/Modal/Modal.tsx +++ b/src/components/Modal/Modal.tsx @@ -63,7 +63,8 @@ const Modal: FC = ({ const onModalClose = () => (onClose ? onClose() : unsetModal()) useShortcut({ - callback: disableKeyboardShortcut ? noop : onModalClose, + callback: + disableKeyboardShortcut || hideCloseButton ? noop : onModalClose, key: 'Escape', keyEvent: 'keydown' }) diff --git a/src/components/Timezone/index.tsx b/src/components/Timezone/index.tsx index 87c93359..7284a5a2 100644 --- a/src/components/Timezone/index.tsx +++ b/src/components/Timezone/index.tsx @@ -1,26 +1,38 @@ import isNull from 'lodash/isNull' import { getTimezoneDefaultValue, mappedTimezoneOpts } from './utils' -import React, { FC } from 'react' +import React, { ChangeEventHandler, FC, useEffect } from 'react' import { Select, SelectProps } from 'components/Select' export interface TimezoneProps extends Omit< SelectProps, - 'defaultValue' | 'options' | 'optionsConfig' | 'showSearch' | 'value' + | 'defaultValue' + | 'options' + | 'onChange' + | 'optionsConfig' + | 'showSearch' + | 'value' > { + onChange?: (value?: string) => void format?: string // null is so an empty defaultValue can be passed through react-hook-form without console.warnings. If a value is null, the component will guess the timezone value?: string | null } export const Timezone: FC = ({ + onChange, value, ...rest }: TimezoneProps) => { + // if value is null and we're guessing the user's tz, then call onChange with the new value + useEffect(() => { + if (isNull(value) && onChange) onChange(getTimezoneDefaultValue(value)) + }, [onChange, value]) + return (