Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OverlayPanel Toast #5236

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 24 additions & 30 deletions components/doc/overlaypanel/datatabledoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ export function DataTableDoc(props) {
const toast = useRef(null);
const isMounted = useRef(false);

useEffect(() => {
if (isMounted.current && selectedProduct) {
op.current.hide();
toast.current.show({ severity: 'info', summary: 'Product Selected', detail: selectedProduct.name, life: 3000 });
}
}, [selectedProduct]); // eslint-disable-line react-hooks/exhaustive-deps
const productSelect = (e) => {
op.current.hide();
toast.current.show({ severity: 'info', summary: 'Product Selected', detail: e.data.name, life: 3000 });
};

useEffect(() => {
isMounted.current = true;
Expand Down Expand Up @@ -99,12 +97,10 @@ export default function DataTableDemo() {
const toast = useRef(null);
const isMounted = useRef(false);

useEffect(() => {
if (isMounted.current && selectedProduct) {
op.current.hide();
toast.current.show({ severity: 'info', summary: 'Product Selected', detail: selectedProduct.name, life: 3000 });
}
}, [selectedProduct]);
const productSelect = (e) => {
op.current.hide();
toast.current.show({ severity: 'info', summary: 'Product Selected', detail:e.data.name, life: 3000 });
};

useEffect(() => {
isMounted.current = true;
Expand Down Expand Up @@ -133,11 +129,11 @@ export default function DataTableDemo() {
<Button type="button" icon="pi pi-search" label="Search" onClick={(e) => op.current.toggle(e)} />
{selectedProductContent}
<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} />
<Column field="price" header="Price" sortable body={priceBody} style={{minWidth: '8rem'}} />
</DataTable>
<DataTable value={products} selectionMode="single" paginator rows={5} selection={selectedProduct} onSelectionChange={(e) => setSelectedProduct(e.value)} onRowClick={productSelect}>
<Column field="name" header="Name" sortable style={{ minWidth: '12rem' }} />
<Column header="Image" body={imageBody} />
<Column field="price" header="Price" sortable body={priceBody} style={{minWidth: '8rem'}} />
</DataTable>
</OverlayPanel>
</div>
);
Expand Down Expand Up @@ -172,13 +168,11 @@ export default function DataTableDemo() {
<span className="text-600">{selectedProduct.category}</span>
</div>
);

useEffect(() => {
if (isMounted.current && selectedProduct) {
op.current.hide();
toast.current.show({ severity: 'info', summary: 'Product Selected', detail: selectedProduct.name, life: 3000 });
}
}, [selectedProduct]);

const productSelect = (e) => {
op.current.hide();
toast.current.show({ severity: 'info', summary: 'Product Selected', detail:e.data.name, life: 3000 });
};

useEffect(() => {
isMounted.current = true;
Expand Down Expand Up @@ -207,11 +201,11 @@ export default function DataTableDemo() {
<Button type="button" icon="pi pi-search" label="Search" onClick={(e) => op.current.toggle(e)} />
{selectedProductContent}
<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} />
<Column field="price" header="Price" sortable body={priceBody} style={{minWidth: '8rem'}} />
</DataTable>
<DataTable value={products} selectionMode="single" paginator rows={5} selection={selectedProduct} onSelectionChange={(e) => setSelectedProduct(e.value)} onRowClick={productSelect}>
<Column field="name" header="Name" sortable style={{ minWidth: '12rem' }} />
<Column header="Image" body={imageBody} />
<Column field="price" header="Price" sortable body={priceBody} style={{minWidth: '8rem'}} />
</DataTable>
</OverlayPanel>
</div>
);
Expand Down Expand Up @@ -248,7 +242,7 @@ export default function DataTableDemo() {
<Button type="button" icon="pi pi-search" label="Search" onClick={(e) => op.current.toggle(e)} />
{selectedProductContent}
<OverlayPanel ref={op} showCloseIcon closeOnEscape dismissable={false}>
<DataTable value={products} selectionMode="single" paginator rows={5} selection={selectedProduct} onSelectionChange={(e) => setSelectedProduct(e.value)}>
<DataTable value={products} selectionMode="single" paginator rows={5} selection={selectedProduct} onSelectionChange={(e) => setSelectedProduct(e.value)} onRowClick={productSelect}>
<Column field="name" header="Name" sortable style={{ minWidth: '12rem' }} />
<Column header="Image" body={imageBody} />
<Column field="price" header="Price" sortable body={priceBody} style={{ minWidth: '8rem' }} />
Expand Down
Loading