Skip to content

Commit

Permalink
Use GUIDs for ephemeral PluginWidgets (rojo-rbx#784)
Browse files Browse the repository at this point in the history
Because Roact will destroy and recreate a plugin widget if it unmounts
and remounts, Studio will complain about making a new widget with the
same ID as the old one.

The simplest solution is to just use GUIDs so we never have to worry
about this again. The ID is used internally for storing the widget's
dock state and other internal details, so we don't want *all* our
widgets to use GUIDs, only the ephemeral popup ones.
  • Loading branch information
boatbomber authored Sep 18, 2023
1 parent e11ad47 commit 840e9be
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugin/src/App/Components/Studio/StudioPluginGui.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
local HttpService = game:GetService("HttpService")

local Rojo = script:FindFirstAncestor("Rojo")
local Plugin = Rojo.Plugin
local Packages = Rojo.Packages
Expand Down Expand Up @@ -36,7 +38,7 @@ function StudioPluginGui:init()
minimumSize.Y
)

local pluginGui = self.props.plugin:CreateDockWidgetPluginGui(self.props.id, dockWidgetPluginGuiInfo)
local pluginGui = self.props.plugin:CreateDockWidgetPluginGui(if self.props.isEphemeral then HttpService:GenerateGUID(false) else self.props.id, dockWidgetPluginGuiInfo)

pluginGui.Name = self.props.id
pluginGui.Title = self.props.title
Expand Down
2 changes: 2 additions & 0 deletions plugin/src/App/StatusPages/Confirming.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ function ConfirmingPage:render()
id = "Rojo_ConfirmingSourceDiff",
title = "Source diff",
active = self.state.showingSourceDiff,
isEphemeral = true,

initDockState = Enum.InitialDockState.Float,
overridePreviousState = true,
Expand Down Expand Up @@ -182,6 +183,7 @@ function ConfirmingPage:render()
self.props.confirmData.serverInfo.projectName or "UNKNOWN"
),
active = true,
isEphemeral = true,

initDockState = Enum.InitialDockState.Float,
overridePreviousState = false,
Expand Down
1 change: 1 addition & 0 deletions plugin/src/App/StatusPages/Connected.lua
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ function ConnectedPage:render()
id = "Rojo_ConnectedSourceDiff",
title = "Source diff",
active = self.state.showingSourceDiff,
isEphemeral = true,

initDockState = Enum.InitialDockState.Float,
overridePreviousState = false,
Expand Down
1 change: 1 addition & 0 deletions plugin/src/App/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ function App:render()
id = pluginName,
title = pluginName,
active = self.state.guiEnabled,
isEphemeral = false,

initDockState = Enum.InitialDockState.Right,
overridePreviousState = false,
Expand Down

0 comments on commit 840e9be

Please sign in to comment.