Browse Source

Fix: "Append params" switch of CopyDropdown does not work when multiple CopyDropdown instance exists

Yuki Takei 5 years ago
parent
commit
a909f8b526
2 changed files with 8 additions and 4 deletions
  1. 1 1
      CHANGES.md
  2. 7 3
      src/client/js/components/Page/CopyDropdown.jsx

+ 1 - 1
CHANGES.md

@@ -2,7 +2,7 @@
 
 
 ## v4.1.1-RC
 ## v4.1.1-RC
 
 
-* 
+* Fix: "Append params" switch of CopyDropdown does not work when multiple CopyDropdown instance exists
 
 
 ## v4.1.0
 ## v4.1.0
 
 

+ 7 - 3
src/client/js/components/Page/CopyDropdown.jsx

@@ -21,6 +21,8 @@ class CopyDropdown extends React.Component {
       isParamsAppended: true,
       isParamsAppended: true,
     };
     };
 
 
+    this.id = (Math.random() * 1000).toString();
+
     this.toggle = this.toggle.bind(this);
     this.toggle = this.toggle.bind(this);
     this.showToolTip = this.showToolTip.bind(this);
     this.showToolTip = this.showToolTip.bind(this);
     this.generatePagePathWithParams = this.generatePagePathWithParams.bind(this);
     this.generatePagePathWithParams = this.generatePagePathWithParams.bind(this);
@@ -97,7 +99,9 @@ class CopyDropdown extends React.Component {
     const pagePathUrl = this.generatePagePathUrl();
     const pagePathUrl = this.generatePagePathUrl();
     const permalink = this.generatePermalink();
     const permalink = this.generatePermalink();
 
 
-    const { DropdownItemContents } = this;
+    const { id, DropdownItemContents } = this;
+
+    const customSwitchForParamsId = `customSwitchForParams_${id}`;
 
 
     return (
     return (
       <>
       <>
@@ -120,12 +124,12 @@ class CopyDropdown extends React.Component {
               <div className="px-3 custom-control custom-switch custom-switch-sm">
               <div className="px-3 custom-control custom-switch custom-switch-sm">
                 <input
                 <input
                   type="checkbox"
                   type="checkbox"
-                  id="customSwitchForParams"
+                  id={customSwitchForParamsId}
                   className="custom-control-input"
                   className="custom-control-input"
                   checked={isParamsAppended}
                   checked={isParamsAppended}
                   onChange={e => this.setState({ isParamsAppended: !isParamsAppended })}
                   onChange={e => this.setState({ isParamsAppended: !isParamsAppended })}
                 />
                 />
-                <label className="custom-control-label small" htmlFor="customSwitchForParams">Append params</label>
+                <label className="custom-control-label small" htmlFor={customSwitchForParamsId}>Append params</label>
               </div>
               </div>
             </div>
             </div>