From 3219d9f3510c190f8eec04825158b9ce2d5f213c Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 15 Mar 2024 14:35:23 -0500 Subject: [PATCH] doing extra guards for actionMap and actionText range to ensure a valid ActionLabelAttribute gets created. Signed-off-by: Matt Bruce --- MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift index 0b12b5a9..b394993a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Label/Label.swift @@ -418,6 +418,8 @@ extension Label { /// Underlines the tappable region and stores the tap logic for interation. private func setTextLinkState(range: NSRange, actionBlock: @escaping ActionBlock) { + guard range.length > 0 else { return } + var textLink = ActionLabelAttribute(location: range.location, length: range.length) textLink.subscriber = textLink .action @@ -437,6 +439,8 @@ extension Label { } public func createActionBlockFor(actionMap: [AnyHashable: Any]?, additionalData: [AnyHashable: Any]?, delegateObject: DelegateObject?) -> ActionBlock? { + guard let actionMap else { return nil } + return { [weak self] in guard let self = self else { return }