Hi Syncfusion Team,
I'm currently developing a Flutter 3 web application that includes a chatbot with PDF viewer functionality. For this, I’m using the syncfusion_flutter_pdfviewer package. However, I’ve encountered an issue where the native right-click context menu is disabled on the page where the PDF viewer is embedded. This prevents users from accessing common right-click functions such as "Inspect", "Copy", "Paste" or "Reload" in the browser, which is essential for debugging and user interaction.
If I completely remove the PDF package from the application, the right click functionality works fine without any issues throughout the entire website. However, once the PDF package has loaded the PDF, the native right click functionality gets completely disabled in all screens of the website, and will only reactivate itself by reloading the entire website.
Steps to Reproduce:
syncfusion_flutter_pdfviewer in a Flutter web project.Expected Behavior:
The default right-click context menu should appear.
Actual Behavior:
The right-click context menu does not appear anywhere on the page with the PDF viewer.
Source code:
SfPdfViewer.memory(
pdfFileUint8List,
enableTextSelection: false,
canShowTextSelectionMenu: false,
canShowScrollHead: false,
interactionMode: chatController.getPDFInteractionMode(),
currentSearchTextHighlightColor: HIGHLIGHT_COLOUR_PDF,
otherSearchTextHighlightColor: HIGHLIGHT_COLOUR_PDF,
controller: chatController.getPdfViewerController(),
onDocumentLoadFailed: (PdfDocumentLoadFailedDetails details) {},
),
Additional Info:
I’d appreciate any insights or a workaround if available.
Thank you in advance for your support!
Hi Busca,
We’d like to clarify that the Syncfusion Flutter PDF Viewer hides the built-in context menu of the browser when interacting with the displayed PDF. This behaviour helps to avoid conflicts between the internal context menu of the Flutter PDF Viewer and the browser’s built-in context menu.
However, we understand that the browser's context menu is currently hidden even when the right-click is performed outside the PDF viewer. Currently, we are finding options to hide the built-in context menu only when clicked inside the PDF Viewer, allowing it to appear elsewhere in the application as expected, we will update further details on November 13, 2024.
Regards,
Krithiga Perumal.
Hi Busca,
As mentioned earlier, hiding the built-in context menu of the browser is implemented in the Syncfusion Flutter PDF Viewer to avoid conflicts between the internal context menu of the PDF Viewer and the browser’s built-in context menu.
We are using web.window.document API from the web package to disable the browser’s default context menu across the entire application window. We explored that, it isn’t feasible to target the PDF Viewer element alone within the window, so the built-in context menu is hidden for the entire page when the PDF Viewer is active.
However, we can adjust this to restore the built-in context menu functionality on other screens in the application once the PDF viewer widget is removed from the widget tree. This approach would allow right-click actions elsewhere in the application after exiting the PDF Viewer screen.
Could you confirm if this approach aligns with your requirements? Based on your confirmation, we will proceed to further analyze this approach.
Regards,
Krithiga Perumal.
Hi Krithiga,
Thank you for the detailed explanation regarding the implementation of the built-in context menu in the Syncfusion Flutter PDF Viewer.
Unfortunately, the proposed approach does not align with our requirements. In our application, the PDF Viewer is used alongside a ChatBot interface, where users often need to use the native context menu to interact with various elements on the page. Disabling the browser's built-in context menu for the entire page, even temporarily, disrupts this functionality and impacts the user experience.
We would prefer a solution that specifically targets the PDF Viewer element alone, without affecting the rest of the page. If this is not feasible, we'd like to go with the approach you mentioned.
Yours truly,
Hi Busca,
We understand your preference for requiring the built-in browser's context menu to be hidden specifically for the PDF Viewer element alone, without impacting the rest of the page. Currently, as mentioned earlier, it is not feasible to disable the browser’s built-in context menu for the PDF Viewer element alone.
We are currently evaluating the option of restoring the built-in browser’s context menu functionality on other screens in the application once the PDF viewer widget is removed from the widget tree. Once the analysis is complete, we will update you with further details. Thank you for your patience and understanding.
Regards,
Krithiga Perumal.
Hi Busca,
We have completed analyzing the proposed approach of restoring the built-in browser’s context menu functionality on other screens in the application once the PDF viewer widget is removed from the widget tree, and we inform you that a solution will be provided by November 27th. Thank you for your patience and understanding.
Please follow this feedback link to track the status:
https://www.syncfusion.com/feedback/63356/browsers-context-menu-becomes-permanently-disabled-in-the-application-after
Regards,
Krithiga Perumal.
Hi Busca,
Sorry for the inconvenience caused.
We are unable to include the fix for "restoring the built-in browser’s context menu functionality on other screens in the application once the PDF viewer widget is removed from the widget tree" in November 26 weekly release. The fix will be included in the December 3rd, 2024, weekly release.
Please follow this feedback link to track the status:
Regards,
Krithiga Perumal.
Hi Busca,
We have resolved the issue where the browser's context is permanently disabled when using the SfPdfViewer widget, and the fix for the same is available in our latest weekly release.
Package link: syncfusion_flutter_pdfviewer 27.2.5
Root cause: Previously, we have disabled the browser's context menu once the PDF document is loaded in the viewer. Now, we have enabled the browser's context menu when the SfPdfViewer is disposed.
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.
Regards,
Imman Kumar P