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

Image editor not working inside of modal or bootstrap nav and tabs #472

Open
aayalapalacin opened this issue Jun 7, 2024 · 1 comment
Open
Labels
enhancement New feature or request Waiting release The issue's code is added in the dev. branch but not yet released

Comments

@aayalapalacin
Copy link

Screen.Recording.2024-06-07.at.11.08.25.AM.mov

Image editor is working in my project, but I want it to only render when I click on a tab, but for some reason the editing functionality isn't working anymore.

here is the bootstrap component: https://getbootstrap.com/docs/4.0/components/navs/#javascript-behavior

here's my component:

<nav>
   <div class="nav nav-tabs" id="nav-tab" role="tablist">
        <a 
          class="nav-item nav-link active"
          id="text-editor-tab" data-toggle="tab" 
          href="#text-editor" 
           role="tab" 
           aria- controls="text-editor" 
            aria-selected="true"
           >
              Text Editor
           </a>
          <a 
            class="nav-item nav-link" 
              id="edit-photo-tab" 
               data-toggle="tab" 
               href="#edit-photo" 
              role="tab" 
               aria-controls="edit-photo"
               aria-selected="false"
             >
               Edit Photo
           </a>
            <a 
             class="nav-item nav-link"
             id="advanced-info-tab" 
              data-toggle="tab" 
             href="#advanced-info" 
             role="tab"
             aria-controls="advanced-info" 
                aria-selected="false"
               >
                 Advanced Info
            </a>
	   <a 
            class="nav-item nav-link" 
              id="image-info-tab" 
             data-toggle="tab" 
           href="#image-info" 
            role="tab" 
             aria-controls="image-info" 
              aria-selected="false"
               >
                 Image Info
             </a>

      </div>
</nav>

<div class="tab-content" id="nav-tabContent">
  <div class="tab-pane fade show active" id="text-editor" role="tabpanel" aria-labelledby="text-editor-tab">
       <textarea class="ckeditor" style="width:99%;" id="editor1" name="content"></textarea>
  </div>
  <div class="tab-pane fade" id="edit-photo" role="tabpanel" aria-labelledby="edit-photo-tab">
	<div id="image-editor" ></div>
  </div>
  <div class="tab-pane fade" id="advanced-info" role="tabpanel" aria-labelledby="advanced-info-tab">advanced info</div>
	<div class="tab-pane fade" id="image-info" role="tabpanel" aria-labelledby="image-info-tab">image info</div>

</div>
<script src="https://scaleflex.cloudimg.io/v7/plugins/filerobot-image-editor/latest/filerobot-image-editor.min.js?func=proxy"></script>
<script src="../RFAssets/js/edit-image.js" ></script>
<script src="/RFassets/js/ckeditor.js"></script>

here is my js file:

window.onload = function() {


  const imageSrc = document.getElementById('rfzone-001').src;
console.log("imageSrc",imageSrc)
const container = document.getElementById("image-editor");

const config = {
  source: imageSrc
};
const ImageEditor = new window.FilerobotImageEditor(container, config);

ImageEditor.render({
  // additional config provided while rendering
  observePluginContainerSize: true,
  onBeforeSave: () => {
    
    return false;
  },
  onSave: (imageInfo, designState) => {
    console.log("yeah", imageInfo,designState)
  
  }
});
}

@AhmeeedMostafa
Copy link
Collaborator

Hey @aayalapalacin ,

the issue was happening due to the bootstrap nav sets display: none to the wrapper of the editor hence the dimensions of that wrapper become with width & height = 0 & 0 and the editor's canvas follows the wrapper's dimensions so it becomes 0 which means no more draw process would be there.

We have fixed that issue from our side by avoiding to set the canvas dimensions with 0, 0 even if the wrapper is 0, 0 but not released yet.

For a tmp. solution from your side, you could use visibility: hidden instead of display: none if possible or avoid using display: none and replace it with some trick like position: absolute; left: -9999px; ...etc.

@AhmeeedMostafa AhmeeedMostafa added enhancement New feature or request Waiting release The issue's code is added in the dev. branch but not yet released labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Waiting release The issue's code is added in the dev. branch but not yet released
Projects
None yet
Development

No branches or pull requests

2 participants