Skip to content

Commit

Permalink
Merge pull request BabylonJS#11291 from BlakeOne/master
Browse files Browse the repository at this point in the history
Fix copying snippet id to clipboard for Chrome
  • Loading branch information
sebavan authored Oct 18, 2021
2 parents 71c5678 + 36d4d94 commit ac9dcc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions dist/preview release/what's new.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@

### GUI

- Allow Chrome to copy the GUI snippet id to the clipboard ([BlakeOne](https://github.com/BlakeOne))
- Added a `FocusableButton` gui control to simplify creating menus with keyboard navigation ([Flux159](https://github.com/Flux159))
- Added `focus()` and `blur()` functions for controls that implement `IFocusableControl` ([Flux159](https://github.com/Flux159))
- Added `ToggleButton` GUI control ([kintz09](https://github.com/kintz09))
Expand Down
14 changes: 10 additions & 4 deletions guiEditor/src/components/propertyTab/propertyTabComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,16 @@ export class PropertyTabComponent extends React.Component<IPropertyTabComponentP
const savePromise = this.props.globalState.customSave?.action || this.saveToSnippetServerHelper;
savePromise(content, adt).then((snippetId: string) => {
adt.snippetId = snippetId;
if (navigator.clipboard) {
navigator.clipboard.writeText(adt.snippetId);
}
alert("GUI saved with ID: " + adt.snippetId + " (please note that the id was also saved to your clipboard)");
const alertMessage = `GUI saved with ID: ${adt.snippetId}`;
if (navigator.clipboard) {
navigator.clipboard.writeText(adt.snippetId).then(() => {
alert(`${alertMessage}. The ID was copied to your clipboard.`);
}).catch((err: any) => {
alert(alertMessage);
})
} else {
alert(alertMessage);
}
this.props.globalState.onBuiltObservable.notifyObservers();
}).catch((err: any) => {
alert(err);
Expand Down

0 comments on commit ac9dcc3

Please sign in to comment.