Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/DialogueEditor/components/Checkbox/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,28 @@ local function Checkbox(properties: CheckboxProperties)
local colors = useStudioColors();
local icons = useStudioIcons();
local buttonRef = React.useRef(nil :: TextButton?);
React.useEffect(function()

React.useEffect(function(): ()

local button = buttonRef.current;
assert(button, "Button reference should not be nil.");

if isDisabled then return end;
local activatedConnection: RBXScriptConnection? = nil;

local activatedConnection = VirtualService.events.GuiButton.Activated:getSignal(button):Connect(function()
if not isDisabled then

onChanged(not isChecked);
activatedConnection = VirtualService.events.GuiButton.Activated:getSignal(button):Connect(function()

end);
onChanged(not isChecked);

end);

end;

button:SetAttribute("IsChecked", isChecked);

return function()

if activatedConnection then

activatedConnection:Disconnect();
Expand All @@ -48,7 +54,7 @@ local function Checkbox(properties: CheckboxProperties)

end;

end, {onChanged :: unknown, isDisabled});
end, {onChanged :: unknown, isDisabled, isChecked});

return React.createElement("Frame", {
AutomaticSize = Enum.AutomaticSize.XY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ local function DialogueTypeDropdown(properties: DialogueTypeDropdownProperties)

end;

task.wait();
Selection:Set({selectedScript});

finishHistoryRecording(historyIdentifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,39 @@ return {
end).toFinishBeforeSeconds(1);

end);

it(`can toggle "IsDisabled" attribute on ContentScript`, function()

expect(function()

local selectedScript = render("Message");

assert(screenGui, "ScreenGui should be initialized before running tests.");
local dynamicContentCheckbox = screenGui:FindFirstChildOfClass("Frame");
assert(dynamicContentCheckbox, "DynamicContentCheckbox should be rendered.");

local checkbox = dynamicContentCheckbox:FindFirstChild("Checkbox");
assert(checkbox and checkbox:IsA("TextButton"), "Checkbox should be rendered inside DynamicContentCheckbox.");

VirtualService.events.GuiButton.Activated:fireEvent(checkbox);
local contentScript = selectedScript:WaitForChild("ContentScript");
verifyReactStatus();
checkbox:GetAttributeChangedSignal("IsChecked"):Wait();
expect(contentScript:GetAttribute("IsDisabled")).toBe(false);

VirtualService.events.GuiButton.Activated:fireEvent(checkbox);
checkbox:GetAttributeChangedSignal("IsChecked"):Wait();
verifyReactStatus();
expect(contentScript:GetAttribute("IsDisabled")).toBe(true);

VirtualService.events.GuiButton.Activated:fireEvent(checkbox);
checkbox:GetAttributeChangedSignal("IsChecked"):Wait();
verifyReactStatus();
expect(contentScript:GetAttribute("IsDisabled")).toBe(false);

end).toFinishBeforeSeconds(1);

end);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local function useDialogueContentScript(dialogueScript: ModuleScript): (ModuleSc

local childAddedConnection = dialogueScript.ChildAdded:Connect(updateDialogueContentScript);
local childRemovedConnection = dialogueScript.ChildRemoved:Connect(updateDialogueContentScript);
updateDialogueContentScript();
task.spawn(updateDialogueContentScript);

return function()

Expand Down