Skip to content

Commit

Permalink
Created a ref to store if the onCloseSettingsSheet is consumed.
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-alexander committed Nov 11, 2021
1 parent b47cfd0 commit 3255826
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/components/src/mobile/link-settings/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function LinkSettings( {
const [ urlInputValue, setUrlInputValue ] = useState( '' );
const [ labelInputValue, setLabelInputValue ] = useState( '' );
const [ linkRelInputValue, setLinkRelInputValue ] = useState( '' );
const onCloseSettingsSheetConsumed = useRef( false );
const prevEditorSidebarOpenedRef = useRef();

const { onHandleClosingBottomSheet } = useContext( BottomSheetContext );
Expand Down Expand Up @@ -174,6 +175,13 @@ function LinkSettings( {
}, [ urlInputValue, labelInputValue, linkRelInputValue, setAttributes ] );

const onCloseSettingsSheet = useCallback( () => {
if ( onCloseSettingsSheetConsumed.current ) {
onCloseSettingsSheetConsumed.current = false;
return;
}

onCloseSettingsSheetConsumed.current = true;

onSetAttributes();

if ( onClose ) {
Expand Down

0 comments on commit 3255826

Please sign in to comment.