Fix currency update (#11088)

## Context
Currency picker was not working properly, clicking a value was
triggering the clickOutsideListener of the parent and was closing the
select without saving. We are now toggling the click outside listener
based on the state of the currency picker dropdown
This also means the UX changed a bit, now choosing a value or clicking
outside only closes the select (allowing you to choose the amount as
well) and only enter OR clicking outside will save
This commit is contained in:
Weiko
2025-03-21 13:56:03 +01:00
committed by GitHub
parent cecb32cd89
commit 77ee016d6f

View File

@ -8,6 +8,8 @@ import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { CurrencyPickerHotkeyScope } from '../types/CurrencyPickerHotkeyScope';
import { TableHotkeyScope } from '@/object-record/record-table/types/TableHotkeyScope';
import { useClickOutsideListener } from '@/ui/utilities/pointer-event/hooks/useClickOutsideListener';
import { CurrencyPickerDropdownSelect } from './CurrencyPickerDropdownSelect';
const StyledDropdownButtonContainer = styled.div`
@ -67,6 +69,10 @@ export const CurrencyPickerDropdownButton = ({
closeDropdown();
};
const { toggleClickOutsideListener } = useClickOutsideListener(
TableHotkeyScope.CellEditMode,
);
const currency = currencies.find(({ value }) => value === valueCode);
const currencyCode = currency?.value ?? CurrencyCode.USD;
@ -92,6 +98,8 @@ export const CurrencyPickerDropdownButton = ({
}
dropdownPlacement="bottom-start"
dropdownOffset={{ x: 0, y: 4 }}
onOpen={() => toggleClickOutsideListener(false)}
onClose={() => toggleClickOutsideListener(true)}
/>
);
};