Skip to content

Commit

Permalink
Correctly manage the disable status by delegating it to the provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
joselrio committed Aug 23, 2023
1 parent de408c6 commit b0b5ced
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,10 @@ namespace Providers.OSUI.Dropdown.VirtualSelect {

// Manage the attributes to be added
private _manageAttributes(): void {
// Check if the pattern should be in disabled mode
this._manageDisableStatus();

// Manage A11Y attributes
this.setA11YProperties();
}

// Manage the disable status of the pattern
private _manageDisableStatus(): void {
if (this.configs.IsDisabled) {
OSFramework.OSUI.Helper.Dom.Attribute.Set(
this.selfElement,
OSFramework.OSUI.GlobalEnum.HTMLAttributes.Disabled,
''
);
} else {
OSFramework.OSUI.Helper.Dom.Attribute.Remove(
this.selfElement,
OSFramework.OSUI.GlobalEnum.HTMLAttributes.Disabled
);
}
}

// Prevent the default behaviour of the event
private _onMouseUp(event) {
event.preventDefault();
Expand Down Expand Up @@ -275,8 +256,6 @@ namespace Providers.OSUI.Dropdown.VirtualSelect {
if (this.isBuilt) {
switch (propertyName) {
case OSFramework.OSUI.Patterns.Dropdown.Enum.Properties.IsDisabled:
this._manageDisableStatus();
break;
case Enum.Properties.NoOptionsText:
case Enum.Properties.NoResultsText:
case Enum.Properties.OptionsList:
Expand Down Expand Up @@ -319,10 +298,9 @@ namespace Providers.OSUI.Dropdown.VirtualSelect {
* @memberof Providers.OSUI.Dropdown.VirtualSelect.AbstractVirtualSelect
*/
public disable(): void {
if (this.configs.IsDisabled === false) {
if (this.configs.IsDisabled === false && this.provider !== undefined) {
this.configs.IsDisabled = true;

this._manageDisableStatus();
this.provider.$ele.disable();
}
}

Expand Down Expand Up @@ -359,10 +337,9 @@ namespace Providers.OSUI.Dropdown.VirtualSelect {
* @memberof Providers.OSUI.Dropdown.VirtualSelect.AbstractVirtualSelect
*/
public enable(): void {
if (this.configs.IsDisabled) {
if (this.configs.IsDisabled && this.provider !== undefined) {
this.configs.IsDisabled = false;

this._manageDisableStatus();
this.provider.$ele.enable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ namespace Providers.OSUI.Dropdown.VirtualSelect {
// Set the library options
this._providerOptions = {
ele: this.ElementId,
disabled: this.IsDisabled,
dropboxWrapper: OSFramework.OSUI.GlobalEnum.HTMLElement.Body,
hasOptionDescription: hasDescription,
hideClearButton: false,
Expand Down

0 comments on commit b0b5ced

Please sign in to comment.