Skip to content

Commit

Permalink
Fix primefaces#4819: Overlay better handling of dissmissible
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Aug 25, 2023
1 parent 5cee939 commit 047ee5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions components/doc/overlaypanel/datatabledoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export default function DataTableDemo() {
<Toast ref={toast} />
<Button type="button" icon="pi pi-search" label="Search" onClick={(e) => op.current.toggle(e)} />
{selectedProductContent}
<OverlayPanel ref={op} showCloseIcon>
<OverlayPanel ref={op} showCloseIcon closeOnEscape dismissable={false}>
<DataTable value={products} selectionMode="single" paginator rows={5} selection={selectedProduct} onSelectionChange={(e) => setSelectedProduct(e.value)}>
<Column field="name" header="Name" sortable style={{minWidth: '12rem'}} />
<Column header="Image" body={imageBody} />
Expand Down Expand Up @@ -206,7 +206,7 @@ export default function DataTableDemo() {
<Toast ref={toast} />
<Button type="button" icon="pi pi-search" label="Search" onClick={(e) => op.current.toggle(e)} />
{selectedProductContent}
<OverlayPanel ref={op} showCloseIcon>
<OverlayPanel ref={op} showCloseIcon closeOnEscape dismissable={false}>
<DataTable value={products} selectionMode="single" paginator rows={5} selection={selectedProduct} onSelectionChange={(e) => setSelectedProduct(e.value)}>
<Column field="name" header="Name" sortable style={{minWidth: '12rem'}} />
<Column header="Image" body={imageBody} />
Expand Down Expand Up @@ -238,13 +238,16 @@ export default function DataTableDemo() {
return (
<>
<DocSectionText {...props}>
<p>An example that displays a DataTable inside a popup to select an item.</p>
<p>
An example that displays a DataTable inside a popup to select an item. <i>closeOnEscape</i> is enabled to close the popop when ESC is pressed. The <i>dismissable</i> property when set to <i>false</i> will not close the popup when
the document is clicked outside the popup.
</p>
</DocSectionText>
<div className="card flex flex-column align-items-center gap-3">
<Toast ref={toast} />
<Button type="button" icon="pi pi-search" label="Search" onClick={(e) => op.current.toggle(e)} />
{selectedProductContent}
<OverlayPanel ref={op} showCloseIcon>
<OverlayPanel ref={op} showCloseIcon closeOnEscape dismissable={false}>
<DataTable value={products} selectionMode="single" paginator rows={5} selection={selectedProduct} onSelectionChange={(e) => setSelectedProduct(e.value)}>
<Column field="name" header="Name" sortable style={{ minWidth: '12rem' }} />
<Column header="Image" body={imageBody} />
Expand Down
4 changes: 2 additions & 2 deletions components/lib/overlaypanel/OverlayPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const OverlayPanel = React.forwardRef((inProps, ref) => {
if (valid) {
switch (type) {
case 'outside':
props.dismissable ? !isPanelClicked.current && hide() : hide();
props.dismissable && !isPanelClicked.current && hide();
break;
case 'resize':
case 'scroll':
Expand All @@ -54,7 +54,7 @@ export const OverlayPanel = React.forwardRef((inProps, ref) => {
when: visibleState
});

useOnEscapeKey(overlayEventListener, props.dismissable && props.closeOnEscape, () => {
useOnEscapeKey(overlayEventListener, props.closeOnEscape, () => {
hide();
});

Expand Down

0 comments on commit 047ee5c

Please sign in to comment.