Skip to content

Commit

Permalink
Merge pull request #408 from qoretechnologies/bugfix/esc-close-bug-co…
Browse files Browse the repository at this point in the history
…llection

Fix hidden modals being added to the escapable modals list
  • Loading branch information
Foxhoundn authored Oct 30, 2024
2 parents 442862f + ebbd277 commit d629e5a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@qoretechnologies/reqore",
"version": "0.48.6",
"version": "0.48.7",
"description": "ReQore is a highly theme-able and modular UI library for React",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/components/Modal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ export const ReqoreModal = ({ width = '80vw', height = 'auto', ...rest }: IReqor
}, [escClosableModals, isEscClosable]);

useEffect(() => {
add(id);
if (rest.isOpen) {
add(id);
}

return () => {
remove(id);
};
}, [id]);
}, [id, rest.isOpen]);

return (
<ReqoreDrawer
Expand Down
60 changes: 43 additions & 17 deletions src/stories/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useMount } from 'react-use';
import { _testsWaitForText } from '../../../__tests__/utils';
import { IReqoreModalProps } from '../../components/Modal';
import { sleep } from '../../helpers/utils';
import { ReqoreModal, ReqorePanel, useReqoreProperty } from '../../index';
import { ReqoreCollection, ReqoreModal, ReqorePanel, useReqoreProperty } from '../../index';
import { StoryMeta } from '../utils';
import { FlatArg, IntentArg, argManager } from '../utils/args';

Expand Down Expand Up @@ -434,22 +434,48 @@ export const EscKeyClosestOnlyTopModal: Story = {
pursuit our but. Lasted hunted enough an up seeing in lively letter. Had judgment out
opinions property the supplied.
</ReqoreModal>
<ReqoreModal
{...args}
label='A second dialog'
isOpen={secondIsOpen}
closeOnEscPress
onClose={() => setSecondIsOpen(false)}
bottomActions={[
{ label: 'Confirm', intent: 'success', position: 'right' },
{ label: 'Cancel', intent: 'danger', position: 'left' },
]}
>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Sit amet purus gravida quis blandit turpis cursus in
hac. Ultricies lacus sed turpis tincidunt. Ac tincidunt vitae semper quis lectus nulla at.
Aliquam vestibulum morbi blandit cursus risus at ultrices. Risus feugiat in ante metus
dictum. Enim blandit volutpat maecenas volutpat.
{secondIsOpen && (
<ReqoreModal
{...args}
label='A second dialog'
isOpen
closeOnEscPress
onClose={() => setSecondIsOpen(false)}
bottomActions={[
{ label: 'Confirm', intent: 'success', position: 'right' },
{ label: 'Cancel', intent: 'danger', position: 'left' },
]}
>
<ReqoreCollection
maxItemHeight={200}
filterable
size='big'
sortable
padded={false}
showSelectedFirst
selectedIcon='CheckLine'
fill
className='q-select-dialog'
inputProps={{
rightIcon: 'KeyboardFill',
focusRules: {
type: 'keypress',
shortcut: 'letters',
clearOnFocus: true,
},
}}
items={[
{ label: 'Item 1' },
{ label: 'Item 2' },
{ label: 'Item 3' },
{ label: 'Item 4' },
]}
/>
</ReqoreModal>
)}
<ReqoreModal label='Hidden modal' closeOnEscPress>
{' '}
I am hidden{' '}
</ReqoreModal>
</>
);
Expand Down

0 comments on commit d629e5a

Please sign in to comment.